com.ibm.di.api.remote.impl.rmi
Class ServerSocketWrapper

java.lang.Object
  extended by java.net.ServerSocket
      extended by com.ibm.di.api.remote.impl.rmi.ServerSocketWrapper

public class ServerSocketWrapper
extends ServerSocket

A wrapper class of ServerSocket class for use by the RMI. ServerSocket class implements server sockets. A server socket waits for requests to come in over the network. It performs some operation based on that request, and then possibly returns a result to the requester.


Constructor Summary
ServerSocketWrapper(ServerSocket aServer)
          Creates an unbound server socket.
 
Method Summary
 Socket accept()
          Listens for a connection to be made to this socket and accepts it.
 void bind(SocketAddress aEndpoint)
          Binds the ServerSocketWrapper to a specific address (IP address and port number).
 void bind(SocketAddress aEndpoint, int aBacklog)
          Binds the ServerSocketWrapper to a specific address (IP address and port number) with specified backlog length.
 void close()
          Closes this socket.
 ServerSocketChannel getChannel()
          Returns the unique ServerSocketChannel object associated with this socket, if any.
 InetAddress getInetAddress()
          Returns the local address of this server socket.
 int getLocalPort()
          Returns the port on which this socket is listening.
 SocketAddress getLocalSocketAddress()
          Returns the address of the endpoint this socket is bound to, or null if it is not bound yet.
 int getReceiveBufferSize()
          Gets the value of the SO_RCVBUF option for this ServerSocketWrapper, that is the proposed buffer size that will be used for Sockets accepted from this ServerSocketWrapper.
 boolean getReuseAddress()
          Tests if SO_REUSEADDR is enabled.
 int getSoTimeout()
          Retrive setting for SO_TIMEOUT.
 boolean isBound()
          Returns the binding state of the ServerSocket.
 boolean isClosed()
          Returns the closed state of the ServerSocketWrapper.
 void setReceiveBufferSize(int aSize)
          Sets a default proposed value for the SO_RCVBUF option for sockets accepted from this ServerSocketWrapper.
 void setReuseAddress(boolean aOn)
          Enable/disable the SO_REUSEADDR socket option.
 void setSoTimeout(int aTimeout)
          Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
 String toString()
          Returns the implementation address and implementation port of this socket as a String.
 
Methods inherited from class java.net.ServerSocket
implAccept, setPerformancePreferences, setSocketFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServerSocketWrapper

public ServerSocketWrapper(ServerSocket aServer)
                    throws IOException
Creates an unbound server socket.

Parameters:
aServer - ServerSocket object
Throws:
IOException - IO error when opening the socket.
Method Detail

bind

public void bind(SocketAddress aEndpoint)
          throws IOException
Binds the ServerSocketWrapper to a specific address (IP address and port number).

Overrides:
bind in class ServerSocket
Parameters:
aEndpoint - The IP address & port number to bind to.
Throws:
IOException - if the bind operation fails, or if the socket is already bound.

bind

public void bind(SocketAddress aEndpoint,
                 int aBacklog)
          throws IOException
Binds the ServerSocketWrapper to a specific address (IP address and port number) with specified backlog length.

Overrides:
bind in class ServerSocket
Parameters:
aEndpoint - The IP address & port number to bind to.
aBacklog - The listen backlog length.
Throws:
IOException - if the bind operation fails, or if the socket is already bound.

getInetAddress

public InetAddress getInetAddress()
Returns the local address of this server socket.

Overrides:
getInetAddress in class ServerSocket
Returns:
the address to which this socket is bound, or null if the socket is unbound.

getLocalPort

public int getLocalPort()
Returns the port on which this socket is listening.

Overrides:
getLocalPort in class ServerSocket
Returns:
the port number to which this socket is listening or -1 if the socket is not bound yet.

getLocalSocketAddress

public SocketAddress getLocalSocketAddress()
Returns the address of the endpoint this socket is bound to, or null if it is not bound yet.

Overrides:
getLocalSocketAddress in class ServerSocket
Returns:
a SocketAddress representing the local endpoint of this socket, or null if it is not bound yet.
See Also:
getInetAddress(), getLocalPort()

accept

public Socket accept()
              throws IOException
Listens for a connection to be made to this socket and accepts it. The method blocks until a connection is made.

Overrides:
accept in class ServerSocket
Returns:
the new SocketWrapper
Throws:
IOException - if an I/O error occurs when waiting for a connection.

close

public void close()
           throws IOException
Closes this socket.

Overrides:
close in class ServerSocket
Throws:
IOException - if an I/O error occurs when closing the socket.

getChannel

public ServerSocketChannel getChannel()
Returns the unique ServerSocketChannel object associated with this socket, if any.

Overrides:
getChannel in class ServerSocket
Returns:
the server-socket channel associated with this socket, or null if this socket was not created for a channel

isBound

public boolean isBound()
Returns the binding state of the ServerSocket.

Overrides:
isBound in class ServerSocket
Returns:
true if the ServerSocketWrapper succesfuly bound to an address

isClosed

public boolean isClosed()
Returns the closed state of the ServerSocketWrapper.

Overrides:
isClosed in class ServerSocket
Returns:
true if the socket has been closed

setSoTimeout

public void setSoTimeout(int aTimeout)
                  throws SocketException
Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.

Overrides:
setSoTimeout in class ServerSocket
Parameters:
aTimeout - the specified timeout, in milliseconds.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.

getSoTimeout

public int getSoTimeout()
                 throws IOException
Retrive setting for SO_TIMEOUT. 0 returns implies that the option is disabled (i.e., timeout of infinity).

Overrides:
getSoTimeout in class ServerSocket
Returns:
the SO_TIMEOUT value
Throws:
IOException - if an I/O error occurs
See Also:
setSoTimeout(int)

setReuseAddress

public void setReuseAddress(boolean aOn)
                     throws SocketException
Enable/disable the SO_REUSEADDR socket option.

Overrides:
setReuseAddress in class ServerSocket
Parameters:
aOn - whether to enable or disable the socket option
Throws:
SocketException - if an error occurs enabling or disabling the SO_RESUEADDR socket option, or the socket is closed.

getReuseAddress

public boolean getReuseAddress()
                        throws SocketException
Tests if SO_REUSEADDR is enabled.

Overrides:
getReuseAddress in class ServerSocket
Returns:
a boolean indicating whether or not SO_REUSEADDR is enabled.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
See Also:
setReuseAddress(boolean)

toString

public String toString()
Returns the implementation address and implementation port of this socket as a String.

Overrides:
toString in class ServerSocket
Returns:
a string representation of this socket.

setReceiveBufferSize

public void setReceiveBufferSize(int aSize)
                          throws SocketException
Sets a default proposed value for the SO_RCVBUF option for sockets accepted from this ServerSocketWrapper.

Overrides:
setReceiveBufferSize in class ServerSocket
Parameters:
aSize - the size to which to set the receive buffer size. This value must be greater than 0.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
See Also:
getReceiveBufferSize()

getReceiveBufferSize

public int getReceiveBufferSize()
                         throws SocketException
Gets the value of the SO_RCVBUF option for this ServerSocketWrapper, that is the proposed buffer size that will be used for Sockets accepted from this ServerSocketWrapper.

Overrides:
getReceiveBufferSize in class ServerSocket
Returns:
the value of the SO_RCVBUF option for this Socket.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
See Also:
setReceiveBufferSize(int)