服务器并不是主动地建立连接.相反地,他们是被动地监听一个客户端的连接请示然后给他们服务.服务器是由类ServerSocket来建立的.下面的程序建立了一个服务器端socket并把它绑定到80端口: ServerSocket serverSocket = new ServerSocket(80, 5); 第一个参数是服务器要监听的端口.
In "Read and write data with Java's I/O streams," we started to explore the input/output (I/O) classes, interfaces, and operations provided by the Java platform. Now, we'll continue our exploration of ...