Code example for Socket

Methods: getSoTimeout, setSoTimeout

0
            sock.close();
        } 
    } 
 
    private int fillInputBuffer(final int timeout) throws IOException {
        final int oldtimeout = this.socket.getSoTimeout();
        try { 
            this.socket.setSoTimeout(timeout);
            return this.inbuffer.fillBuffer();
        } finally { 
            this.socket.setSoTimeout(oldtimeout);
        } 
    } 
 
    protected boolean awaitInput(final int timeout) throws IOException {
        if (this.inbuffer.hasBufferedData()) {
            return true; 
        } 
        fillInputBuffer(timeout);
        return this.inbuffer.hasBufferedData();
    }