public abstract class ServerSocketFactory
extends Object
| java.lang.Object | |
| javax.net.ServerSocketFactory | |
| |
这个类创建服务器套接字。 它可能被其他工厂分类,这些工厂创建特定类型的服务器套接字。 这为添加公共套接字级功能提供了一个通用框架。 它是套接字工厂的服务器端模拟器,同样提供了捕获与正在构建的套接字相关的各种策略的方法。
与套接字工厂一样,服务器套接字工厂实例也有用于创建套接字的方法。 还有一个特定于环境的默认服务器套接字工厂; 框架通常会使用他们自己定制的工厂。
也可以看看:
Protected constructors |
|
|---|---|
ServerSocketFactory() 创建一个服务器套接字工厂。 |
|
公共方法(Public methods) |
|
|---|---|
abstract ServerSocket |
createServerSocket(int port) 返回绑定到指定端口的服务器套接字。 |
ServerSocket |
createServerSocket() 返回未绑定的服务器套接字。 |
abstract ServerSocket |
createServerSocket(int port, int backlog, InetAddress ifAddress) 返回绑定到指定端口的服务器套接字,并指定侦听积压和本地IP。 |
abstract ServerSocket |
createServerSocket(int port, int backlog) 返回绑定到指定端口的服务器套接字,并使用指定的连接backlog。 |
static ServerSocketFactory |
getDefault() 返回环境默认套接字工厂的副本。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
ServerSocket createServerSocket (int port)
返回绑定到指定端口的服务器套接字。 套接字配置了给这个工厂的套接字选项(比如接受超时)。
如果有安全管理器,则使用port参数作为其参数调用其checkListen方法,以确保允许操作。 这可能会导致SecurityException。
| 参数(Parameters) | |
|---|---|
port |
int: the port to listen to |
| 返回(Returns) | |
|---|---|
ServerSocket |
the ServerSocket |
| 抛出异常(Throws) | |
|---|---|
IOException |
for networking errors |
SecurityException |
if a security manager exists and its checkListen method doesn't allow the operation. |
IllegalArgumentException |
if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive. |
ServerSocket createServerSocket ()
返回未绑定的服务器套接字。 套接字配置了给这个工厂的套接字选项(比如接受超时)。
| 返回(Returns) | |
|---|---|
ServerSocket |
the unbound socket |
| 抛出异常(Throws) | |
|---|---|
IOException |
if the socket cannot be created |
ServerSocket createServerSocket (int port, int backlog, InetAddress ifAddress)
返回绑定到指定端口的服务器套接字,并指定侦听积压和本地IP。
ifAddress参数可用于多宿主主机上的一个ServerSocket ,该主机只接受连接请求到其中一个地址。 如果ifAddress为空,它将接受所有本地地址上的连接。 套接字配置了给这个工厂的套接字选项(比如接受超时)。
backlog参数必须是大于0的正值。如果通过的值等于或小于0,则将假定默认值。
如果有安全管理器, checkListen port参数作为其参数调用其checkListen方法,以确保允许操作。 这可能会导致SecurityException。
| 参数(Parameters) | |
|---|---|
port |
int: the port to listen to |
backlog |
int: how many connections are queued |
ifAddress |
InetAddress: the network interface address to use |
| 返回(Returns) | |
|---|---|
ServerSocket |
the ServerSocket |
| 抛出异常(Throws) | |
|---|---|
IOException |
for networking errors |
SecurityException |
if a security manager exists and its checkListen method doesn't allow the operation. |
IllegalArgumentException |
if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive. |
ServerSocket createServerSocket (int port, int backlog)
返回绑定到指定端口的服务器套接字,并使用指定的连接backlog。 套接字配置了给这个工厂的套接字选项(比如接受超时)。
参数 backlog必须是大于0的正值。如果在等于或小于0时传递值,则将假定默认值。
如果有安全管理器, checkListen port参数作为参数调用其checkListen方法,以确保允许操作。 这可能会导致SecurityException。
| 参数(Parameters) | |
|---|---|
port |
int: the port to listen to |
backlog |
int: how many connections are queued |
| 返回(Returns) | |
|---|---|
ServerSocket |
the ServerSocket |
| 抛出异常(Throws) | |
|---|---|
IOException |
for networking errors |
SecurityException |
if a security manager exists and its checkListen method doesn't allow the operation. |
IllegalArgumentException |
if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive. |
ServerSocketFactory getDefault ()
返回环境默认套接字工厂的副本。
| 返回(Returns) | |
|---|---|
ServerSocketFactory |
the ServerSocketFactory |