wjw465150 add socket performance

This commit is contained in:
wjw465150
2011-08-30 17:23:49 +08:00
committed by Eric Hauser
parent 3e8ac6e094
commit a688c610ae

View File

@@ -116,6 +116,13 @@ public class Connection {
if (!isConnected()) {
try {
socket = new Socket();
//->@wjw_add
socket.setReuseAddress(true);
socket.setKeepAlive(true); //Will monitor the TCP connection is valid
socket.setTcpNoDelay(true); //Socket buffer Whetherclosed, to ensure timely delivery of data
socket.setSoLinger(true,0); //Control calls close () method, the underlying socket is closed immediately
//<-@wjw_add
socket.connect(new InetSocketAddress(host, port), timeout);
socket.setSoTimeout(timeout);
outputStream = new RedisOutputStream(socket.getOutputStream());