本帖最后由 Kevin.Kang 于 2015-8-7 20:14 编辑
客户端:
- package com.kxg_07;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.net.Socket;
- public class ClientDemo {
- public static void main(String[] args) throws IOException {
- Socket s = new Socket("10.164.22.254", 48264);
- OutputStream os = s.getOutputStream();
- os.write("hello,TCP".getBytes());
- InputStream is = s.getInputStream();
- byte[] bys = new byte[1024];
- int len = is.read(bys);
- String str = new String(bys, 0, len);
- System.out.println("Server:" + str);
- s.close();
- }
- }
复制代码
|