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

Constructor Index

 o ServerSocket()

Method Index

 o accept()
Accept a connection from a remote client.
 o addSocketConnectionRequestListener(SocketConnectionRequestListener)
 o close()
Close the server socket.
 o create()
Creates the server socket.
 o create(int)
Creates the server socket.
 o finalize()
 o getConnectionRequestEnabled()
 o getSocketConnectionRequestListeners()
 o handleSocketConnectionRequest(SocketConnectionRequestEvent)
SocketConnectionRequestEvent handler
 o removeSocketConnectionRequestListener(SocketConnectionRequestListener)
 o ResetAsynchronous(boolean)
 o ResetLocalPort(int)
 o ResetRemotePort(int)
Remote port cannot be set on a server socket.
 o toString()
Override of toString method of Object.

Constructors

 o ServerSocket
  public ServerSocket()

Methods

 o finalize
  protected void finalize()
Overrides:
finalize in class Object
 o addSocketConnectionRequestListener
  public synchronized void addSocketConnectionRequestListener(SocketConnectionRequestListener l)
 o getSocketConnectionRequestListeners
  public synchronized EventListenerVector getSocketConnectionRequestListeners()
 o handleSocketConnectionRequest
  public synchronized void handleSocketConnectionRequest(SocketConnectionRequestEvent data)
SocketConnectionRequestEvent handler
 o removeSocketConnectionRequestListener
  public synchronized void removeSocketConnectionRequestListener(SocketConnectionRequestListener l)
 o create
  public synchronized boolean create()
Creates the server socket.
Returns:
true if and only if the socket was successfully created.
See Also:
create
 o 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
 o 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
 o close
  public boolean close()
Close the server socket.
Returns:
true if the socket was successfully closed.
Overrides:
close in class BaseSocket
 o toString
  public String toString()
Override of toString method of Object.
Overrides:
toString in class Object
 o ResetLocalPort
  protected boolean ResetLocalPort(int port)
Overrides:
ResetLocalPort in class BaseSocket
 o 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
 o ResetAsynchronous
  protected boolean ResetAsynchronous(boolean value)
Overrides:
ResetAsynchronous in class BaseSocket
 o getConnectionRequestEnabled
  protected boolean getConnectionRequestEnabled()

All Packages  Class Hierarchy  This Package  Previous  Next  Index