Freigeben über


Socket.LocalSocketAddress Property

Definition

Returns the address of the endpoint this socket is bound to.

public virtual Java.Net.SocketAddress? LocalSocketAddress { [Android.Runtime.Register("getLocalSocketAddress", "()Ljava/net/SocketAddress;", "GetGetLocalSocketAddressHandler")] get; }
[<get: Android.Runtime.Register("getLocalSocketAddress", "()Ljava/net/SocketAddress;", "GetGetLocalSocketAddressHandler")>]
member this.LocalSocketAddress : Java.Net.SocketAddress

Property Value

a SocketAddress representing the local endpoint of this socket, or a SocketAddress representing the loopback address if denied by the security manager, or null if the socket is not bound yet.

Attributes

Remarks

Returns the address of the endpoint this socket is bound to.

If a socket bound to an endpoint represented by an InetSocketAddress is #close closed, then this method will continue to return an InetSocketAddress after the socket is closed. In that case the returned InetSocketAddress's address is the InetAddress#isAnyLocalAddress wildcard address and its port is the local port that it was bound to.

If there is a security manager set, its checkConnect method is called with the local address and -1 as its arguments to see if the operation is allowed. If the operation is not allowed, a SocketAddress representing the InetAddress#getLoopbackAddress loopback address and the local port to which this socket is bound is returned.

Added in 1.4.

Java documentation for java.net.Socket.getLocalSocketAddress().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to