java 网络编程 Socket连接
?import java.net.*;import java.io.*;public class TCPServer {public static void main(String[] args) throws Exception {ServerSocket ss = new ServerSocket(6666);while(true) {Socket s = ss.accept();DataInputStream dis = new DataInputStream(s.getInputStream());System.out.println(dis.readUTF());dis.close();s.close();}}}
?
摘自马士兵视频例子