服务端可以显示客户端的数据
^C[root@io socket]# java SocketServerBIOTest server started , port : 9090 client 56944 connected!!! client read some data is :30 val :asdfasdfasdfasfdfasdfasdfasdas服务端执行nestat -ntap,
[root@io ~]# netstat -ntap Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name ... tcp6 0 0 192.168.205.138:9090 192.168.205.149:56944 ESTABLISHED 2266/java ...可以看到已经分配了一个PID,通过:
lsof -p 2266查看这个java进程相关的文件描述符
[root@io ~]# lsof -p 2266 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ... java 2266 root 6u IPv6 26479 0t0 TCP 192.168.205.138:websm->192.168.205.149:56944 (ESTABLISHED) ...6u就对应了服务端和客户端连接的一个Socket。
以上演示的是一个BIO的模型,在具体的编程中,服务端和客户端都有很多配置的参数。详见:socketOpt