Dela via


Socket.Connect Method

Definition

Overloads

Connect(SocketAddress)

Connects this socket to the server.

Connect(SocketAddress, Int32)

Connects this socket to the server with a specified timeout value.

Connect(SocketAddress)

Connects this socket to the server.

[Android.Runtime.Register("connect", "(Ljava/net/SocketAddress;)V", "GetConnect_Ljava_net_SocketAddress_Handler")]
public virtual void Connect (Java.Net.SocketAddress? endpoint);
[<Android.Runtime.Register("connect", "(Ljava/net/SocketAddress;)V", "GetConnect_Ljava_net_SocketAddress_Handler")>]
abstract member Connect : Java.Net.SocketAddress -> unit
override this.Connect : Java.Net.SocketAddress -> unit

Parameters

endpoint
SocketAddress

the SocketAddress

Attributes

Exceptions

if the given SocketAddress is invalid or not supported.

if the socket is already connected or an error occurs while connecting.

Remarks

Connects this socket to the server.

Added in 1.4.

Java documentation for java.net.Socket.connect(java.net.SocketAddress).

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

Connect(SocketAddress, Int32)

Connects this socket to the server with a specified timeout value.

[Android.Runtime.Register("connect", "(Ljava/net/SocketAddress;I)V", "GetConnect_Ljava_net_SocketAddress_IHandler")]
public virtual void Connect (Java.Net.SocketAddress? endpoint, int timeout);
[<Android.Runtime.Register("connect", "(Ljava/net/SocketAddress;I)V", "GetConnect_Ljava_net_SocketAddress_IHandler")>]
abstract member Connect : Java.Net.SocketAddress * int -> unit
override this.Connect : Java.Net.SocketAddress * int -> unit

Parameters

endpoint
SocketAddress

the SocketAddress

timeout
Int32

the timeout value to be used in milliseconds.

Attributes

Exceptions

if the given SocketAddress is invalid or not supported or the timeout value is negative.

if the socket is already connected or an error occurs while connecting.

Remarks

Connects this socket to the server with a specified timeout value. A timeout of zero is interpreted as an infinite timeout. The connection will then block until established or an error occurs.

Added in 1.4.

Java documentation for java.net.Socket.connect(java.net.SocketAddress, 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