标签:os ar java sp on c ad r new
服务器端:
public class TCPServer{
public static void main(String[]args){
ServerSocket ss = new ServerSocket(6666);
while(true){
Socket s = ss.accept();
System.out.println("a client connent!");
DataInputStream dis = new DataInputStream(ss.getInputStream());
System.out.println(dis.readUTF());
dis.close();
s.close();
}
}
}
客户端:
public class TCPClient{
public static void main(String[]args){
Socket s = new Socket(“127.0.0.1”,6666);
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
dos.writeUTF("Hello World!");
dos.flush();
dos.close();
s.close();
}
}
标签:os ar java sp on c ad r new
原文地址:http://www.cnblogs.com/oraclespace/p/3997377.html