Code example for Socket

Methods: setSoLinger, setSoTimeout, setTcpNoDelay

0
    } 
 
    void setSocketOptions(Socket socket)
        throws SocketException { 
        if(linger >= 0 ) 
            socket.setSoLinger( true, linger);
        if( tcpNoDelay )
            socket.setTcpNoDelay(tcpNoDelay);
        if( socketTimeout > 0 )
            socket.setSoTimeout( socketTimeout );
    } 
 
     
    void processSocket(Socket s, TcpConnection con, Object[] threadData) {
        // Process the connection 
        int step = 1;
        try { 
             
            // 1: Set socket options: timeout, linger, etc 
            setSocketOptions(s);