ice.net
Interface SimpleSocket

All Known Implementing Classes:
ClientSocket

public interface SimpleSocket

Version:
1.5.2
Author:
Jack van Ooststroom

Method Summary
 void close()
          Closes the SimpleSocket.
 InetAddress getInetAddress()
          Gets the remote IP address to which the SimpleSocket is connected.
 InputStream getInputStream()
          Gets the input stream of the SimpleSocket.
 OutputStream getOutputStream()
          Gets the output stream of the SimpleSocket.
 int getPort()
          Gets the remote port to which the SimpleSocket is connected.
 int getSoTimeout()
          Gets the SO_TIMEOUT int value.
 boolean getTcpNoDelay()
          Gets the TCP_NODELAY boolean value.
 void setSoTimeout(int timeout)
          Sets the SO_TIMEOUT to the specified timeout in milliseconds.
 void setTcpNoDelay(boolean on)
          Sets the TCP_NODELAY to the specified on boolean.
 boolean useIp()
          Checks to see if the SimpleSocket needs to use the IP (Internet Protocol).
 

Method Detail

close

public void close()
           throws IOException

Closes the SimpleSocket.

Any thread currently blocked in an I/O operation upon the SimpleSocket will throw a SocketException.

Once the SimpleSocket has been closed, it is not available for further networking use. A new SimpleSocket needs to be created.

Throws:
IOException - if an I/O error occurs when closing the SimpleSocket.
Since:
1.5.2

getInetAddress

public InetAddress getInetAddress()

Gets the remote IP address to which the SimpleSocket is connected.

Returns:
the remote IP address.
Since:
1.5.2

getPort

public int getPort()

Gets the remote port to which the SimpleSocket is connected.

Returns:
the remote port.
Since:
1.5.2

getInputStream

public InputStream getInputStream()
                           throws IOException

Gets the input stream of the SimpleSocket.

Returns:
the input stream.
Throws:
IOException - if an I/O error occurs when creating the input stream or the SimpleSocket is closed.
Since:
1.5.2
See Also:
getOutputStream()

getOutputStream

public OutputStream getOutputStream()
                             throws IOException

Gets the output stream of the SimpleSocket.

Returns:
the output stream.
Throws:
IOException - if an I/O error occurs when creating the output stream or the SimpleSocket is closed.
Since:
1.5.2
See Also:
getInputStream()

getSoTimeout

public int getSoTimeout()
                 throws SocketException

Gets the SO_TIMEOUT int value. 0 implies that the option is disabled (i.e., a timeout of infinity).

Returns:
the SO_TIMEOUT int value.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
1.5.2
See Also:
setSoTimeout(int)

getTcpNoDelay

public boolean getTcpNoDelay()
                      throws SocketException

Gets the TCP_NODELAY boolean value.

Returns:
true if TCP_NODELAY is enabled, false if not.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
1.5.2
See Also:
setTcpNoDelay(boolean)

setSoTimeout

public void setSoTimeout(int timeout)
                  throws IllegalArgumentException,
                         SocketException

Sets the SO_TIMEOUT to the specified timeout in milliseconds.

With this option set to a non-zero timeout, a read() call on the InputStream associated with the SimpleSocket will block for only this amount of time. If the timeout expires, a SocketTimeoutException is raised, though the SimpleSocket is still valid. The option must be enabled prior to entering the blocking operation to have effect. A timeout of zero is interpreted as an infinite timeout.

Parameters:
timeout - the new timeout in milliseconds.
Throws:
IllegalArgumentException - if the specified timeout is lesser than 0.
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
1.5.2
See Also:
getSoTimeout()

setTcpNoDelay

public void setTcpNoDelay(boolean on)
                   throws SocketException

Sets the TCP_NODELAY to the specified on boolean. This will disable/enable Nagle's algorithm.

Parameters:
on - true to enable TCP_NODELAY, false to disable.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
1.5.2
See Also:
getTcpNoDelay()

useIp

public boolean useIp()

Checks to see if the SimpleSocket needs to use the IP (Internet Protocol).

Returns:
true if the SimpleSocket needs to use the IP, false if not.
Since:
1.5.2