SocketFactory.CreateSocket Method

Definition

Overloads

CreateSocket()

Creates an unconnected socket.

CreateSocket(InetAddress, Int32)

Creates a socket and connects it to the specified port number at the specified address.

CreateSocket(String, Int32)

Creates a socket and connects it to the specified remote host at the specified remote port.

CreateSocket(InetAddress, Int32, InetAddress, Int32)

Creates a socket and connect it to the specified remote address on the specified remote port.

CreateSocket(String, Int32, InetAddress, Int32)

Creates a socket and connects it to the specified remote host on the specified remote port.

CreateSocket()

Creates an unconnected socket.

[Android.Runtime.Register("createSocket", "()Ljava/net/Socket;", "GetCreateSocketHandler")]
public virtual Java.Net.Socket? CreateSocket ();
[<Android.Runtime.Register("createSocket", "()Ljava/net/Socket;", "GetCreateSocketHandler")>]
abstract member CreateSocket : unit -> Java.Net.Socket
override this.CreateSocket : unit -> Java.Net.Socket

Returns

Socket

the unconnected socket

Attributes

Exceptions

if an error occurs while creating a new socket.

Remarks

Java documentation for javax.net.SocketFactory.createSocket().

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

CreateSocket(InetAddress, Int32)

Creates a socket and connects it to the specified port number at the specified address.

[Android.Runtime.Register("createSocket", "(Ljava/net/InetAddress;I)Ljava/net/Socket;", "GetCreateSocket_Ljava_net_InetAddress_IHandler")]
public abstract Java.Net.Socket? CreateSocket (Java.Net.InetAddress? host, int port);
[<Android.Runtime.Register("createSocket", "(Ljava/net/InetAddress;I)Ljava/net/Socket;", "GetCreateSocket_Ljava_net_InetAddress_IHandler")>]
abstract member CreateSocket : Java.Net.InetAddress * int -> Java.Net.Socket

Parameters

host
InetAddress

the server host

port
Int32

the server port

Returns

Socket

the Socket

Attributes

Exceptions

if an error occurs while creating a new socket.

Remarks

Java documentation for javax.net.SocketFactory.createSocket(java.net.InetAddress, 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

CreateSocket(String, Int32)

Creates a socket and connects it to the specified remote host at the specified remote port.

[Android.Runtime.Register("createSocket", "(Ljava/lang/String;I)Ljava/net/Socket;", "GetCreateSocket_Ljava_lang_String_IHandler")]
public abstract Java.Net.Socket? CreateSocket (string? host, int port);
[<Android.Runtime.Register("createSocket", "(Ljava/lang/String;I)Ljava/net/Socket;", "GetCreateSocket_Ljava_lang_String_IHandler")>]
abstract member CreateSocket : string * int -> Java.Net.Socket

Parameters

host
String

the server host name with which to connect, or null for the loopback address.

port
Int32

the server port

Returns

Socket

the Socket

Attributes

Exceptions

if an error occurs while creating a new socket.

if the specified host is unknown or the IP address could not be resolved.

Remarks

Java documentation for javax.net.SocketFactory.createSocket(java.lang.String, 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

CreateSocket(InetAddress, Int32, InetAddress, Int32)

Creates a socket and connect it to the specified remote address on the specified remote port.

[Android.Runtime.Register("createSocket", "(Ljava/net/InetAddress;ILjava/net/InetAddress;I)Ljava/net/Socket;", "GetCreateSocket_Ljava_net_InetAddress_ILjava_net_InetAddress_IHandler")]
public abstract Java.Net.Socket? CreateSocket (Java.Net.InetAddress? address, int port, Java.Net.InetAddress? localAddress, int localPort);
[<Android.Runtime.Register("createSocket", "(Ljava/net/InetAddress;ILjava/net/InetAddress;I)Ljava/net/Socket;", "GetCreateSocket_Ljava_net_InetAddress_ILjava_net_InetAddress_IHandler")>]
abstract member CreateSocket : Java.Net.InetAddress * int * Java.Net.InetAddress * int -> Java.Net.Socket

Parameters

address
InetAddress

the server network address

port
Int32

the server port

localAddress
InetAddress

the client network address

localPort
Int32

the client port

Returns

Socket

the Socket

Attributes

Exceptions

if an error occurs while creating a new socket.

Remarks

Java documentation for javax.net.SocketFactory.createSocket(java.net.InetAddress, int, java.net.InetAddress, 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

CreateSocket(String, Int32, InetAddress, Int32)

Creates a socket and connects it to the specified remote host on the specified remote port.

[Android.Runtime.Register("createSocket", "(Ljava/lang/String;ILjava/net/InetAddress;I)Ljava/net/Socket;", "GetCreateSocket_Ljava_lang_String_ILjava_net_InetAddress_IHandler")]
public abstract Java.Net.Socket? CreateSocket (string? host, int port, Java.Net.InetAddress? localHost, int localPort);
[<Android.Runtime.Register("createSocket", "(Ljava/lang/String;ILjava/net/InetAddress;I)Ljava/net/Socket;", "GetCreateSocket_Ljava_lang_String_ILjava_net_InetAddress_IHandler")>]
abstract member CreateSocket : string * int * Java.Net.InetAddress * int -> Java.Net.Socket

Parameters

host
String

the server host name with which to connect, or null for the loopback address.

port
Int32

the server port

localHost
InetAddress

the local address the socket is bound to

localPort
Int32

the local port the socket is bound to

Returns

Socket

the Socket

Attributes

Exceptions

if an error occurs while creating a new socket.

if the specified host is unknown or the IP address could not be resolved.

Remarks

Java documentation for javax.net.SocketFactory.createSocket(java.lang.String, int, java.net.InetAddress, 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