标签:
通过在如何使用socket进行java网络编程(一)中程序的编写,可以总结出一些常用的java socket编程的范例来。
ServerSocket server = new ServerSocket(_PORT_); while (true) { Socket nextClient = server.accept(); SocketHandler handler = new SocketHandler(nextClient); Thread t = new Thread(handler); t.start(); } public class SocketHandler implements Runnable { private Socket socket = null; public SocketHandler(Socket socket) { super(); this.socket = socket; } @Override public void run() { //具体的报文处理逻辑 } }
标签:
原文地址:http://www.cnblogs.com/lyhero11/p/4836437.html