Condividi tramite


DatagramSocketImpl.Connect(InetAddress, Int32) Method

Definition

Connects a datagram socket to a remote destination.

[Android.Runtime.Register("connect", "(Ljava/net/InetAddress;I)V", "GetConnect_Ljava_net_InetAddress_IHandler")]
protected virtual void Connect (Java.Net.InetAddress? address, int port);
[<Android.Runtime.Register("connect", "(Ljava/net/InetAddress;I)V", "GetConnect_Ljava_net_InetAddress_IHandler")>]
abstract member Connect : Java.Net.InetAddress * int -> unit
override this.Connect : Java.Net.InetAddress * int -> unit

Parameters

address
InetAddress

the remote InetAddress to connect to

port
Int32

the remote port number

Attributes

Exceptions

if the datagram socket cannot be connected to the specified remote address and port.

Remarks

Connects a datagram socket to a remote destination. This associates the remote address with the local socket so that datagrams may only be sent to this destination and received from this destination. This may be overridden to call a native system connect.

If the remote destination to which the socket is connected does not exist, or is otherwise unreachable, and if an ICMP destination unreachable packet has been received for that address, then a subsequent call to send or receive may throw a PortUnreachableException. Note, there is no guarantee that the exception will be thrown.

Added in 1.4.

Java documentation for java.net.DatagramSocketImpl.connect(java.net.InetAddress, int).

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