Mono Class Library: System.Net.Sockets.Socket Overview | Members

System.Net.Sockets.Socket.BeginConnect Method

Begins an asynchronous operation to associate the current instance with a remote endpoint. [Edit]

public IAsyncResult BeginConnect (System.Net.EndPoint end_point, AsyncCallback callback, object state)

Parameters

end_point
Documentation for this section has not yet been entered. [Edit]
callback
A AsyncCallback delegate, or null. [Edit]
state
An application-defined object, or null. [Edit]

Returns

A IAsyncResult instance that contains information about the asynchronous operation. [Edit]

Permissions

TypeReason
System.Net.SocketPermission [Edit] Requires permission to make a connection to the endpoint defined by remoteEP.

Exceptions

TypeReason
ArgumentNullExceptionremoteEP is null. [Edit]
System.Net.Sockets.SocketException
Note: For additional information on causes of the SocketException, see the System.Net.Sockets.SocketException class.
[Edit]
ObjectDisposedExceptionThe current instance has been disposed. [Edit]
System.Security.SecurityExceptionA caller higher in the call stack does not have permission for the requested operation. [Edit]

Remarks

To release resources allocated by the Socket.BeginConnect(System.Net.EndPoint, AsyncCallback, object) method, call the Socket.EndConnect(IAsyncResult) method, and specify the IAsyncResult object returned by this method.

Note: The Socket.EndConnect(IAsyncResult) method should be called exactly once for each call to the Socket.BeginConnect(System.Net.EndPoint, AsyncCallback, object) method.

If the callback parameter is not null, the method referenced by callback is invoked when the asynchronous operation completes. The IAsyncResult object returned by this method is passed as the argument to the method referenced by callback. The method referenced by callback can retrieve the results of the operation by calling the Socket.EndConnect(IAsyncResult) method.

The state parameter can be any object that the caller wishes to have available for the duration of the asynchronous operation. This object is available via the IAsyncResult.AsyncState property of the object returned by this method.

To determine the connection status, check the Socket.Connected property, or use either the Socket.Poll(int, SelectMode) or Socket.Select(IList, IList, IList, int) method.

Note:

For more information, see Socket.Connect(System.Net.EndPoint), the synchronous version of this method.

[Edit]

Example

For an outline of an asynchronous operation, see the Socket.BeginAccept(AsyncCallback, object) method. For the complete example, which uses the Socket.BeginConnect(System.Net.EndPoint, AsyncCallback, object) method, see the System.Net.Sockets.Socket class overview.

Requirements

Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0