Code example for Socket

Methods: getPort

0
        } 
    } 
 
    public int getRemotePort() { 
        if (this.socket != null) {
            return this.socket.getPort();
        } else { 
            return -1; 
        } 
    } 
 
    public void setSocketTimeout(int timeout) {
        assertOpen(); 
        if (this.socket != null) {
            try { 
                this.socket.setSoTimeout(timeout);
            } catch (SocketException ignore) {
                // It is not quite clear from the Sun's documentation if there are any 
                // other legitimate cases for a socket exception to be thrown when setting 
                // SO_TIMEOUT besides the socket being already closed 
            }