Sdílet prostřednictvím


ISocketFactory.ConnectSocket Method

Definition

Connects a socket to the given host.

[Android.Runtime.Register("connectSocket", "(Ljava/net/Socket;Ljava/lang/String;ILjava/net/InetAddress;ILorg/apache/http/params/HttpParams;)Ljava/net/Socket;", "GetConnectSocket_Ljava_net_Socket_Ljava_lang_String_ILjava_net_InetAddress_ILorg_apache_http_params_HttpParams_Handler:Org.Apache.Http.Conn.Schemes.ISocketFactoryInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public Java.Net.Socket? ConnectSocket (Java.Net.Socket? sock, string? host, int port, Java.Net.InetAddress? localAddress, int localPort, Org.Apache.Http.Params.IHttpParams? params);
[<Android.Runtime.Register("connectSocket", "(Ljava/net/Socket;Ljava/lang/String;ILjava/net/InetAddress;ILorg/apache/http/params/HttpParams;)Ljava/net/Socket;", "GetConnectSocket_Ljava_net_Socket_Ljava_lang_String_ILjava_net_InetAddress_ILorg_apache_http_params_HttpParams_Handler:Org.Apache.Http.Conn.Schemes.ISocketFactoryInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member ConnectSocket : Java.Net.Socket * string * int * Java.Net.InetAddress * int * Org.Apache.Http.Params.IHttpParams -> Java.Net.Socket

Parameters

sock
Socket

the socket to connect, as obtained from #createSocket createSocket. null indicates that a new socket should be created and connected.

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

localPort
Int32

the port on the local machine, 0 or a negative number for any

params
IHttpParams

additional HttpParams parameters for connecting

Returns

the connected socket. The returned object may be different from the sock argument if this factory supports a layered protocol.

Attributes

Exceptions

if an I/O error occurs

if the IP address of the target host can not be determined

if the socket cannot be connected within the time limit defined in the params

Remarks

Connects a socket to the given host.

Java documentation for org.apache.http.conn.scheme.SocketFactory.connectSocket(java.net.Socket, java.lang.String, int, java.net.InetAddress, int, org.apache.http.params.HttpParams).

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