socket = new Socket(); //TIME_WAIT状态下可以复用端口 socket.setReuseAddress(true); //空闲时发送数据包,确认服务端状态 socket.setKeepAlive(true); //关闭Nagle算法,尽快发送 socket.setTcpNoDelay(true); //调用close方法立即关闭socket,丢弃所有未发送的数据包 socket.setSoLinger(true, 0); //连接server socket.connect(new InetSocketAddress(host, port), connectionTimeout); //设置读取时超时时间 socket.setSoTimeout(soTimeout);
标签:socket,数据包,常见,Tcp,发送,参数,new,true From: https://www.cnblogs.com/lzmrex/p/9230437.html