Język

ISocketFactoryExtensions.ConnectSocketAsync Method

Definition

Runs the socket factory's connection operation as a task.

public static System.Threading.Tasks.Task<Java.Net.Socket?> ConnectSocketAsync(this Org.Apache.Http.Conn.Schemes.ISocketFactory self, Java.Net.Socket? sock, string? host, int port, Java.Net.InetAddress? localAddress, int localPort, Org.Apache.Http.Params.IHttpParams? params);
static member ConnectSocketAsync : Org.Apache.Http.Conn.Schemes.ISocketFactory * Java.Net.Socket * string * int * Java.Net.InetAddress * int * Org.Apache.Http.Params.IHttpParams -> System.Threading.Tasks.Task<Java.Net.Socket>

Parameters

sock
Socket

The socket to connect, or null to create and connect a new socket.

host
String

The name of the remote host.

port
Int32

The port number on the remote host.

localAddress
InetAddress

The local address to bind to, or null to use any local address.

localPort
Int32

The local port number, or zero or a negative number to use any local port.

params
IHttpParams

The parameters that control the connection.

Returns

A task whose result is the socket returned by self.ConnectSocket(sock, host, port, localAddress, localPort, params). This socket can differ from sock when the factory uses a layered protocol.

Remarks

This .NET extension method uses System.Threading.Tasks.Task.Run to call the synchronous ConnectSocket(Socket, String, Int32, InetAddress, Int32, IHttpParams) method on self. It does not use native asynchronous socket I/O and has no cancellation token parameter. Exceptions from the synchronous call are stored in the returned task.

For the generated implementation, see the .NET for Android async extension generator.

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