Package com.ibm.di.api.remote.impl.rmi
Class ServerSocketWrapper
- java.lang.Object
-
- java.net.ServerSocket
-
- com.ibm.di.api.remote.impl.rmi.ServerSocketWrapper
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class ServerSocketWrapper extends java.net.ServerSocketA 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
Constructors Constructor Description ServerSocketWrapper(java.net.ServerSocket aServer)Creates an unbound server socket.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.net.Socketaccept()Listens for a connection to be made to this socket and accepts it.voidbind(java.net.SocketAddress aEndpoint)Binds theServerSocketWrapperto a specific address (IP address and port number).voidbind(java.net.SocketAddress aEndpoint, int aBacklog)Binds theServerSocketWrapperto a specific address (IP address and port number) with specified backlog length.voidclose()Closes this socket.java.nio.channels.ServerSocketChannelgetChannel()Returns the uniqueServerSocketChannelobject associated with this socket, if any.java.net.InetAddressgetInetAddress()Returns the local address of this server socket.intgetLocalPort()Returns the port on which this socket is listening.java.net.SocketAddressgetLocalSocketAddress()Returns the address of the endpoint this socket is bound to, ornullif it is not bound yet.intgetReceiveBufferSize()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.booleangetReuseAddress()Tests if SO_REUSEADDR is enabled.intgetSoTimeout()Retrive setting for SO_TIMEOUT.booleanisBound()Returns the binding state of the ServerSocket.booleanisClosed()Returns the closed state of the ServerSocketWrapper.voidsetReceiveBufferSize(int aSize)Sets a default proposed value for the SO_RCVBUF option for sockets accepted from this ServerSocketWrapper.voidsetReuseAddress(boolean aOn)Enable/disable the SO_REUSEADDR socket option.voidsetSoTimeout(int aTimeout)Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.java.lang.StringtoString()Returns the implementation address and implementation port of this socket as aString.
-
-
-
Method Detail
-
bind
public void bind(java.net.SocketAddress aEndpoint) throws java.io.IOExceptionBinds theServerSocketWrapperto a specific address (IP address and port number).- Overrides:
bindin classjava.net.ServerSocket- Parameters:
aEndpoint- The IP address & port number to bind to.- Throws:
java.io.IOException- if the bind operation fails, or if the socket is already bound.
-
bind
public void bind(java.net.SocketAddress aEndpoint, int aBacklog) throws java.io.IOExceptionBinds theServerSocketWrapperto a specific address (IP address and port number) with specified backlog length.- Overrides:
bindin classjava.net.ServerSocket- Parameters:
aEndpoint- The IP address & port number to bind to.aBacklog- The listen backlog length.- Throws:
java.io.IOException- if the bind operation fails, or if the socket is already bound.
-
getInetAddress
public java.net.InetAddress getInetAddress()
Returns the local address of this server socket.- Overrides:
getInetAddressin classjava.net.ServerSocket- Returns:
- the address to which this socket is bound, or
nullif the socket is unbound.
-
getLocalPort
public int getLocalPort()
Returns the port on which this socket is listening.- Overrides:
getLocalPortin classjava.net.ServerSocket- Returns:
- the port number to which this socket is listening or -1 if the socket is not bound yet.
-
getLocalSocketAddress
public java.net.SocketAddress getLocalSocketAddress()
Returns the address of the endpoint this socket is bound to, ornullif it is not bound yet.- Overrides:
getLocalSocketAddressin classjava.net.ServerSocket- Returns:
- a
SocketAddressrepresenting the local endpoint of this socket, ornullif it is not bound yet. - See Also:
getInetAddress(),getLocalPort()
-
accept
public java.net.Socket accept() throws java.io.IOExceptionListens for a connection to be made to this socket and accepts it. The method blocks until a connection is made.- Overrides:
acceptin classjava.net.ServerSocket- Returns:
- the new SocketWrapper
- Throws:
java.io.IOException- if an I/O error occurs when waiting for a connection.
-
close
public void close() throws java.io.IOExceptionCloses this socket.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.net.ServerSocket- Throws:
java.io.IOException- if an I/O error occurs when closing the socket.
-
getChannel
public java.nio.channels.ServerSocketChannel getChannel()
Returns the uniqueServerSocketChannelobject associated with this socket, if any.- Overrides:
getChannelin classjava.net.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:
isBoundin classjava.net.ServerSocket- Returns:
- true if the ServerSocketWrapper succesfuly bound to an address
-
isClosed
public boolean isClosed()
Returns the closed state of the ServerSocketWrapper.- Overrides:
isClosedin classjava.net.ServerSocket- Returns:
- true if the socket has been closed
-
setSoTimeout
public void setSoTimeout(int aTimeout) throws java.net.SocketExceptionEnable/disable SO_TIMEOUT with the specified timeout, in milliseconds.- Overrides:
setSoTimeoutin classjava.net.ServerSocket- Parameters:
aTimeout- the specified timeout, in milliseconds.- Throws:
java.net.SocketException- if there is an error in the underlying protocol, such as a TCP error.
-
getSoTimeout
public int getSoTimeout() throws java.io.IOExceptionRetrive setting for SO_TIMEOUT. 0 returns implies that the option is disabled (i.e., timeout of infinity).- Overrides:
getSoTimeoutin classjava.net.ServerSocket- Returns:
- the SO_TIMEOUT value
- Throws:
java.io.IOException- if an I/O error occurs- See Also:
setSoTimeout(int)
-
setReuseAddress
public void setReuseAddress(boolean aOn) throws java.net.SocketExceptionEnable/disable the SO_REUSEADDR socket option.- Overrides:
setReuseAddressin classjava.net.ServerSocket- Parameters:
aOn- whether to enable or disable the socket option- Throws:
java.net.SocketException- if an error occurs enabling or disabling the SO_RESUEADDR socket option, or the socket is closed.
-
getReuseAddress
public boolean getReuseAddress() throws java.net.SocketExceptionTests if SO_REUSEADDR is enabled.- Overrides:
getReuseAddressin classjava.net.ServerSocket- Returns:
- a
booleanindicating whether or not SO_REUSEADDR is enabled. - Throws:
java.net.SocketException- if there is an error in the underlying protocol, such as a TCP error.- See Also:
setReuseAddress(boolean)
-
toString
public java.lang.String toString()
Returns the implementation address and implementation port of this socket as aString.- Overrides:
toStringin classjava.net.ServerSocket- Returns:
- a string representation of this socket.
-
setReceiveBufferSize
public void setReceiveBufferSize(int aSize) throws java.net.SocketExceptionSets a default proposed value for the SO_RCVBUF option for sockets accepted from this ServerSocketWrapper.- Overrides:
setReceiveBufferSizein classjava.net.ServerSocket- Parameters:
aSize- the size to which to set the receive buffer size. This value must be greater than 0.- Throws:
java.net.SocketException- if there is an error in the underlying protocol, such as a TCP error.- See Also:
getReceiveBufferSize()
-
getReceiveBufferSize
public int getReceiveBufferSize() throws java.net.SocketExceptionGets 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:
getReceiveBufferSizein classjava.net.ServerSocket- Returns:
- the value of the SO_RCVBUF option for this Socket.
- Throws:
java.net.SocketException- if there is an error in the underlying protocol, such as a TCP error.- See Also:
setReceiveBufferSize(int)
-
-