Sdílet prostřednictvím


ServerSocketFactory.CreateServerSocket Method

Definition

Overloads

CreateServerSocket()

Returns an unbound server socket.

CreateServerSocket(Int32)

Returns a server socket bound to the specified port.

CreateServerSocket(Int32, Int32)

Returns a server socket bound to the specified port, and uses the specified connection backlog.

CreateServerSocket(Int32, Int32, InetAddress)

Returns a server socket bound to the specified port, with a specified listen backlog and local IP.

CreateServerSocket()

Returns an unbound server socket.

[Android.Runtime.Register("createServerSocket", "()Ljava/net/ServerSocket;", "GetCreateServerSocketHandler")]
public virtual Java.Net.ServerSocket? CreateServerSocket ();
[<Android.Runtime.Register("createServerSocket", "()Ljava/net/ServerSocket;", "GetCreateServerSocketHandler")>]
abstract member CreateServerSocket : unit -> Java.Net.ServerSocket
override this.CreateServerSocket : unit -> Java.Net.ServerSocket

Returns

the unbound socket

Attributes

Exceptions

if an error occurs while creating a new server socket.

Remarks

Returns an unbound server socket. The socket is configured with the socket options (such as accept timeout) given to this factory.

Java documentation for javax.net.ServerSocketFactory.createServerSocket().

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

CreateServerSocket(Int32)

Returns a server socket bound to the specified port.

[Android.Runtime.Register("createServerSocket", "(I)Ljava/net/ServerSocket;", "GetCreateServerSocket_IHandler")]
public abstract Java.Net.ServerSocket? CreateServerSocket (int port);
[<Android.Runtime.Register("createServerSocket", "(I)Ljava/net/ServerSocket;", "GetCreateServerSocket_IHandler")>]
abstract member CreateServerSocket : int -> Java.Net.ServerSocket

Parameters

port
Int32

the port to listen to

Returns

the ServerSocket

Attributes

Exceptions

if an error occurs while creating a new server socket.

Remarks

Returns a server socket bound to the specified port. The socket is configured with the socket options (such as accept timeout) given to this factory.

If there is a security manager, its checkListen method is called with the port argument as its argument to ensure the operation is allowed. This could result in a SecurityException.

Java documentation for javax.net.ServerSocketFactory.createServerSocket(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

CreateServerSocket(Int32, Int32)

Returns a server socket bound to the specified port, and uses the specified connection backlog.

[Android.Runtime.Register("createServerSocket", "(II)Ljava/net/ServerSocket;", "GetCreateServerSocket_IIHandler")]
public abstract Java.Net.ServerSocket? CreateServerSocket (int port, int backlog);
[<Android.Runtime.Register("createServerSocket", "(II)Ljava/net/ServerSocket;", "GetCreateServerSocket_IIHandler")>]
abstract member CreateServerSocket : int * int -> Java.Net.ServerSocket

Parameters

port
Int32

the port to listen to

backlog
Int32

how many connections are queued

Returns

the ServerSocket

Attributes

Exceptions

if an error occurs while creating a new server socket.

Remarks

Returns a server socket bound to the specified port, and uses the specified connection backlog. The socket is configured with the socket options (such as accept timeout) given to this factory.

The backlog argument must be a positive value greater than 0. If the value passed if equal or less than 0, then the default value will be assumed.

If there is a security manager, its checkListen method is called with the port argument as its argument to ensure the operation is allowed. This could result in a SecurityException.

Java documentation for javax.net.ServerSocketFactory.createServerSocket(int, 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

CreateServerSocket(Int32, Int32, InetAddress)

Returns a server socket bound to the specified port, with a specified listen backlog and local IP.

[Android.Runtime.Register("createServerSocket", "(IILjava/net/InetAddress;)Ljava/net/ServerSocket;", "GetCreateServerSocket_IILjava_net_InetAddress_Handler")]
public abstract Java.Net.ServerSocket? CreateServerSocket (int port, int backlog, Java.Net.InetAddress? ifAddress);
[<Android.Runtime.Register("createServerSocket", "(IILjava/net/InetAddress;)Ljava/net/ServerSocket;", "GetCreateServerSocket_IILjava_net_InetAddress_Handler")>]
abstract member CreateServerSocket : int * int * Java.Net.InetAddress -> Java.Net.ServerSocket

Parameters

port
Int32

the port to listen to

backlog
Int32

how many connections are queued

ifAddress
InetAddress

the network interface address to use

Returns

the ServerSocket

Attributes

Exceptions

if an error occurs while creating a new server socket.

Remarks

Returns a server socket bound to the specified port, with a specified listen backlog and local IP.

The ifAddress argument can be used on a multi-homed host for a ServerSocket that will only accept connect requests to one of its addresses. If ifAddress is null, it will accept connections on all local addresses. The socket is configured with the socket options (such as accept timeout) given to this factory.

The backlog argument must be a positive value greater than 0. If the value passed if equal or less than 0, then the default value will be assumed.

If there is a security manager, its checkListen method is called with the port argument as its argument to ensure the operation is allowed. This could result in a SecurityException.

Java documentation for javax.net.ServerSocketFactory.createServerSocket(int, int, java.net.InetAddress).

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