|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.net.ServerSocket
public class ServerSocket
ServerSocket create connections between 'host' and 'client' machines. The ServerSocket listens on a well known port and upon a connection request, instantiates a 'host' sockets, which carries on future communication with the requesting 'client' socket, so that the server socket may continue listening for connection requests. They are passive objects, having no execution thread of their own to listen on.
| Field Summary | |
|---|---|
(package private) static SocketImplFactory |
factory
|
(package private) SocketImpl |
impl
|
| Constructor Summary | |
|---|---|
|
ServerSocket()
Construct a ServerSocket, which is not bound to any port. |
|
ServerSocket(int aport)
Construct a ServerSocket, bound to the nominated port on the default localhost. |
|
ServerSocket(int aport,
int backlog)
Construct a ServerSocket, bound to the nominated port on the default localhost. |
|
ServerSocket(int aport,
int backlog,
InetAddress localAddr)
Construct a ServerSocket, bound to the nominated local host/port. |
protected |
ServerSocket(SocketImpl impl)
|
| Method Summary | |
|---|---|
Socket |
accept()
Retrieve the first connection request and answer the 'host' socket that will conduct further communications with the requesting 'client' socket. |
void |
bind(SocketAddress localAddr)
Bind the ServerSocket to the nominated local host/port. |
void |
bind(SocketAddress localAddr,
int backlog)
Bind the ServerSocket to the nominated local host/port. |
(package private) void |
checkListen(int aPort)
Check whether the server may listen for connection requests on aport. |
void |
close()
Close this server socket. |
(package private) static int |
defaultBacklog()
Answer the default number of pending connections on a server socket. |
ServerSocketChannel |
getChannel()
if ServerSocket is created by a ServerSocketChannel, returns the related ServerSocketChannel |
InetAddress |
getInetAddress()
Answer the local IP address for this server socket. |
int |
getLocalPort()
Answer the local port for this server socket. |
SocketAddress |
getLocalSocketAddress()
Answer the local SocketAddress for this server socket, or null if the socket is not bound. |
int |
getReceiveBufferSize()
Answer the socket receive buffer size (SO_RCVBUF). |
boolean |
getReuseAddress()
Get the state of the SO_REUSEADDR socket option. |
int |
getSoTimeout()
Answer the time-out period of this server socket. |
protected void |
implAccept(Socket aSocket)
Invoke the server socket implementation to accept a connection on the newly created aSocket. |
boolean |
isBound()
Return if the server socket is bound to a local address and port. |
boolean |
isClosed()
Return if the server socket is closed. |
void |
setPerformancePreferences(int connectionTime,
int latency,
int bandwidth)
sets performance preference for connectionTime,latency and bandwidth |
void |
setReceiveBufferSize(int size)
Set the socket receive buffer size. |
void |
setReuseAddress(boolean reuse)
Set the SO_REUSEADDR socket option. |
static void |
setSocketFactory(SocketImplFactory aFactory)
Set the server socket implementation factory. |
void |
setSoTimeout(int timeout)
Set the listen time-out period for this server socket. |
String |
toString()
Returns a string containing a concise, human-readable description of the server socket. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
SocketImpl impl
static SocketImplFactory factory
| Constructor Detail |
|---|
public ServerSocket()
throws IOException
IOExceptionSocketprotected ServerSocket(SocketImpl impl)
public ServerSocket(int aport)
throws IOException
aport - the port number to listen for connection requests on
IOExceptionSocket
public ServerSocket(int aport,
int backlog)
throws IOException
aport - the port number to listen for connection requests onbacklog - the number of pending connection requests, before requests are
rejected
IOExceptionSocket
public ServerSocket(int aport,
int backlog,
InetAddress localAddr)
throws IOException
aport - the port number to listen for connection requests onlocalAddr - the local machine address to bind onbacklog - the number of pending connection requests, before requests are
rejected
IOExceptionSocket| Method Detail |
|---|
public Socket accept()
throws IOException
IOException - if an error occurs while instantiating the 'host' socketvoid checkListen(int aPort)
aport. Throw an exception if the port is outside the
valid range or does not satisfy the security policy.
aPort - the candidate port to listen on
public void close()
throws IOException
IOExceptionstatic int defaultBacklog()
public InetAddress getInetAddress()
public int getLocalPort()
public int getSoTimeout()
throws IOException
SocketException - thrown if option cannot be retrieved
IOException
protected final void implAccept(Socket aSocket)
throws IOException
aSocket.
aSocket - the concrete socketImpl to accept the connection request on
IOException - thrown if connection cannot be accepted
public static void setSocketFactory(SocketImplFactory aFactory)
throws IOException
aFactory - the streaming socket factory to be used for further socket
instantiations
IOException - thrown if the factory is already set
public void setSoTimeout(int timeout)
throws SocketException
timeout - the time to wait for a connection request
SocketException - thrown if an error occurs during setting the optionpublic String toString()
port field is reported a zero, as there
is no connection formed to the server.
toString in class Object
public void bind(SocketAddress localAddr)
throws IOException
localAddr - the local machine address and port to bind on
IllegalArgumentException - if the SocketAddress is not supported
IOException - if the socket is already bound, or a problem occurs during
the bind
public void bind(SocketAddress localAddr,
int backlog)
throws IOException
localAddr - the local machine address and port to bind onbacklog - the number of pending connection requests, before requests are
rejected
IllegalArgumentException - if the SocketAddress is not supported
IOException - if the socket is already bound, or a problem occurs during
the bindpublic SocketAddress getLocalSocketAddress()
public boolean isBound()
public boolean isClosed()
public void setReuseAddress(boolean reuse)
throws SocketException
reuse - the socket SO_REUSEADDR option setting
SocketException
public boolean getReuseAddress()
throws SocketException
SocketException
public void setReceiveBufferSize(int size)
throws SocketException
size - the buffer size, in bytes
SocketException - If an error occurs while setting the size or the size is
invalid.
public int getReceiveBufferSize()
throws SocketException
SocketExceptionpublic ServerSocketChannel getChannel()
public void setPerformancePreferences(int connectionTime,
int latency,
int bandwidth)
connectionTime - the importance of connect timelatency - the importance of latencybandwidth - the importance of bandwidth
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||