WebObjects 5.2.3

com.webobjects.foundation
Class NSSocketUtilities

java.lang.Object
  extended bycom.webobjects.foundation.NSSocketUtilities

public class NSSocketUtilities
extends Object

This class provides an easy way to get a TCP socket (java.net.Socket) with a connection timeout. The static methods in this class correspond to all of the java.net.Socket constructors.
Invoking getSocketWithTimeout either returns a valid socket, or throws an IOException (because the Socket creation timed out, or failed for other reasons). When a new socket is requested with getSocketWithTimeout, a timeout argument (in milliseconds) is passed in, and the socket creation times-out when that timeout is exceeded. Passing a timeout value of 0 will result in the default java.net.Socket creation behavior (i.e. a system dependant timeout).
This class only contains static methods, and should never be instantiated.

See Also:
getSocketWithTimeout(String host, int port, int timeout), getSocketWithTimeout(InetAddress address, int port, int timeout), getSocketWithTimeout(String host, int port, InetAddress localAddress, int localPort, int timeout), getSocketWithTimeout(InetAddress address, int port, InetAddress localAddress, int localPort, int timeout), Socket

Constructor Summary
NSSocketUtilities()
           
 
Method Summary
static Socket getSocketWithTimeout(InetAddress address, int port, InetAddress localAddress, int localPort, int timeout)
          Creates a socket and connects it to the remote address and host specified, using the given timeout in milliseconds.
static Socket getSocketWithTimeout(InetAddress address, int port, int timeout)
          Creates a socket and connects it to the remote port and address specified, using the given timeout in milliseconds.
static Socket getSocketWithTimeout(String host, int port, InetAddress localAddress, int localPort, int timeout)
          Creates a socket and connects it to the remote port and host specified, using the given timeout in milliseconds.
static Socket getSocketWithTimeout(String host, int port, int timeout)
          Creates a socket and connects it to the remote port and host specified, using the given timeout in milliseconds.
static int pollingInterval()
          Deprecated. This method always returns 0.
static void setPollingInterval(int interval)
          Deprecated. This method no longer does anything, and should not be used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NSSocketUtilities

public NSSocketUtilities()
Method Detail

getSocketWithTimeout

public static Socket getSocketWithTimeout(String host,
                                          int port,
                                          int timeout)
                                   throws UnknownHostException,
                                          IOException
Creates a socket and connects it to the remote port and host specified, using the given timeout in milliseconds.

Parameters:
host - specifies the remote host name or IP
port - specifies the remote port
timeout - specifies the connection timeout in milliseconds
Returns:
a new Socket connected to host:port
Throws:
UnknownHostException - host cannot be resolved
IOException - the socket can't be created

getSocketWithTimeout

public static Socket getSocketWithTimeout(String host,
                                          int port,
                                          InetAddress localAddress,
                                          int localPort,
                                          int timeout)
                                   throws UnknownHostException,
                                          IOException
Creates a socket and connects it to the remote port and host specified, using the given timeout in milliseconds. The local end of the socket will be bound to the localPort and localAddress specified.

Parameters:
host - specifies the remote host name or IP
port - specifies the remote port
localAddress - specifies the local address
localPort - specifies the local port
timeout - specifies the connection timeout in milliseconds
Returns:
a new Socket connected to host:port remotely and to localAddress:localPort locally
Throws:
UnknownHostException - host cannot be resolved
IOException - the socket can't be created

getSocketWithTimeout

public static Socket getSocketWithTimeout(InetAddress address,
                                          int port,
                                          int timeout)
                                   throws IOException
Creates a socket and connects it to the remote port and address specified, using the given timeout in milliseconds.

Parameters:
address - specifies the remote host address
port - specifies the remote port
timeout - specifies the connection timeout in milliseconds
Returns:
a new Socket connected to address:port
Throws:
IOException - the socket can't be created

getSocketWithTimeout

public static Socket getSocketWithTimeout(InetAddress address,
                                          int port,
                                          InetAddress localAddress,
                                          int localPort,
                                          int timeout)
                                   throws IOException
Creates a socket and connects it to the remote address and host specified, using the given timeout in milliseconds. The local end of the socket will be bound to the localPort and localAddress specified.

Parameters:
address - specifies the remote host address
port - specifies the remote port
localAddress - specifies the local address
localPort - specifies the local port
timeout - specifies the connection timeout in milliseconds
Returns:
a new Socket connected to address:port remotely and localAddress:localPort locally
Throws:
UnknownHostException - host cannot be resolved
IOException - the socket can't be created

pollingInterval

public static int pollingInterval()
Deprecated. This method always returns 0.


setPollingInterval

public static void setPollingInterval(int interval)
Deprecated. This method no longer does anything, and should not be used.


Last updated Thu Oct 21 15:04:16 PDT 2004.

Copyright © 2004 Apple Computer, Inc.