public int getLocalPort ()

Returns the local port number to which this socket is bound.

If the socket was bound prior to being closed, then this method will continue to return the local port number after the socket is closed.

Returns:  the local port number to which this socket is bound or -1 if the socket is not bound yet.