Class powersoft.jcm.net.ServerSocket
All Packages Class Hierarchy This Package Previous Next Index
Class powersoft.jcm.net.ServerSocket
java.lang.Object
|
+----powersoft.jcm.net.BaseSocket
|
+----powersoft.jcm.net.ServerSocket
- public class ServerSocket
- extends BaseSocket
This class encapsulates a stream-type server socket.
Example:
ServerSocket socket = new ServerSocket();
socket.setLocalPort( 1 );
Socket client = socket.Accept();
if( client != null ) {
String msg;
int received = client.Receive( msg );
if( received > 0 )
System.out.println( msg );
}
- See Also:
- Socket, BaseSocket
-
ServerSocket()
-
-
accept()
- Accept a connection from a remote client.
-
addSocketConnectionRequestListener(SocketConnectionRequestListener)
-
-
close()
- Close the server socket.
-
create()
- Creates the server socket.
-
create(int)
- Creates the server socket.
-
finalize()
-
-
getConnectionRequestEnabled()
-
-
getSocketConnectionRequestListeners()
-
-
handleSocketConnectionRequest(SocketConnectionRequestEvent)
- SocketConnectionRequestEvent handler
-
removeSocketConnectionRequestListener(SocketConnectionRequestListener)
-
-
ResetAsynchronous(boolean)
-
-
ResetLocalPort(int)
-
-
ResetRemotePort(int)
- Remote port cannot be set on a server socket.
-
toString()
- Override of toString method of Object.
ServerSocket
public ServerSocket()
finalize
protected void finalize()
- Overrides:
- finalize in class Object
addSocketConnectionRequestListener
public synchronized void addSocketConnectionRequestListener(SocketConnectionRequestListener l)
getSocketConnectionRequestListeners
public synchronized EventListenerVector getSocketConnectionRequestListeners()
handleSocketConnectionRequest
public synchronized void handleSocketConnectionRequest(SocketConnectionRequestEvent data)
- SocketConnectionRequestEvent handler
removeSocketConnectionRequestListener
public synchronized void removeSocketConnectionRequestListener(SocketConnectionRequestListener l)
create
public synchronized boolean create()
- Creates the server socket.
- Returns:
-
true
if and only if the socket was successfully
created.
- See Also:
- create
create
public synchronized boolean create(int count)
- Creates the server socket.
- Parameters:
- count - The maximum queue length for incoming connection
indications (a request to connect). If a connection
indication arrives when the queue is full, the conneciton
is refused.
If the queue length is not specified, the default is 50.
- Returns:
-
true
if and only if the socket was successfully
created.
- See Also:
- create
accept
public synchronized Socket accept()
- Accept a connection from a remote client.
Notes:
The socket must be created before calling this method.
If not, the LastError property is set to SockENotCreated and
null
is returned.
If the socket is non-asynchronous, this method blocks
until a connection request is received.
If the socket is asynchronous, this method should only be called
in response to a SocketConnectionRequest (to prevent blocking).
The address and port of the client can be obtained by calling
getRemoteInetAddress() and getRemotePort() on the returned socket.
- Returns:
- A socket connected with the remote client.
- See Also:
- SocketExceptionCode, create, getRemoteInetAddress, getRemotePort
close
public boolean close()
- Close the server socket.
- Returns:
-
true
if the socket was successfully closed.
- Overrides:
- close in class BaseSocket
toString
public String toString()
- Override of toString method of Object.
- Overrides:
- toString in class Object
ResetLocalPort
protected boolean ResetLocalPort(int port)
- Overrides:
- ResetLocalPort in class BaseSocket
ResetRemotePort
protected boolean ResetRemotePort(int __unused)
- Remote port cannot be set on a server socket.
The remote host address and port are reset at each call to
Accept().
- Overrides:
- ResetRemotePort in class BaseSocket
ResetAsynchronous
protected boolean ResetAsynchronous(boolean value)
- Overrides:
- ResetAsynchronous in class BaseSocket
getConnectionRequestEnabled
protected boolean getConnectionRequestEnabled()
All Packages Class Hierarchy This Package Previous Next Index