Język

SSLSocketFactory.ConnectSocketAsync Method

Definition

Connects a socket to the given host by running the synchronous method on the thread pool.

public System.Threading.Tasks.Task<Java.Net.Socket?> ConnectSocketAsync(Java.Net.Socket? sock, string? host, int port, Java.Net.InetAddress? localAddress, int localPort, Org.Apache.Http.Params.IHttpParams? params);
member this.ConnectSocketAsync : 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, as obtained from CreateSocket(), or null to create and connect a new socket.

host
String

The host to connect to.

port
Int32

The port to connect to on the host.

localAddress
InetAddress

The local address to bind the socket to, or null for any local address.

localPort
Int32

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

params
IHttpParams

Additional HTTP parameters for the connection.

Returns

A task whose result is the connected socket returned by ConnectSocket(Socket, String, Int32, InetAddress, Int32, IHttpParams).

Remarks

This .NET method uses Task.Run to call ConnectSocket(Socket, String, Int32, InetAddress, Int32, IHttpParams) with the same arguments. It does not use native asynchronous socket I/O. The task preserves the synchronous method's return value, including null. If that method throws an exception, the task records the exception, which is rethrown when the task is awaited.

Source: .NET async method generator.

Portions of this page are based on work created and shared by the Apache Software Foundation and used under the terms of the Apache License, Version 2.0.

Applies to