Documentation Archive Developer
Search
PATH Documentation > WebObjects

Table of Contents

NSSocketUtilities


Inherits from:
Object
Package:
com.webobjects.foundation


Class Description


This class provides an easy way to get a TCP socket with a connection timeout. The static methods in this class correspond to all of the java.net.Socket constructors. See Sun's documentation for the java.net.Socket class for more information.

Calling getSocketWithTimeout will either return a socket, or will throw an IOException if it times out (because a socket cannot be created). When a new socket is requested with getSocketWithTimeout, the polling interval regulates how often that socket is requested. By default, the polling interval is 100 milliseconds, and can be changed using setPollingInterval. A timeout argument is passed to getSocketWithTimeout, and the socket request times out when a timer that keeps track of the total polling time exceeds the timeout value.

This class only contains static methods. It is never instantiated.




Method Types


All methods
getSocketWithTimeout
pollingInterval
setPollingInterval


Static Methods



getSocketWithTimeout

public static java.net.Socket getSocketWithTimeout( String remoteHost, int remotePort, java.net.InetAddress localInetAddress, int localPort, int timeOut) throws java.net.UnknownHostException, java.io.IOException

Creates a socket and connects it to the port specified by remotePort at the host specified by remoteHost. Binds the socket to the local port specified by localPort at the local host specified by localInetAddress with a timeout specified by timeout. Throws an UnknownHostException if remoteHost cannot be resolved. Throws an IOException if the socket can't be created.

public static java.net.Socket getSocketWithTimeout( String remoteHost, int remotePort, int timeout) throws java.net.UnknownHostException, java.io.IOException

Creates a socket and connects it to the port specified by remotePort at the host specified by remoteHost with a timeout specified by timeout. Throws an UnknownHostException if remoteHost cannot be resolved. Throws an IOException if the socket can't be created.

public static java.net.Socket getSocketWithTimeout( InetAddress remoteAddress, int remotePort, int timeout) throws java.io.IOException

Creates a socket and connects it to the port specified by remotePort at the host specified by remoteAddress with a timeout specified by timeout. Throws an IOException if the socket can't be created.

public static Socket getSocketWithTimeout( InetAddress remoteAddress, int remotePort, InetAddress localAddress, int localPort, int timeout) throws java.io.IOException

Creates a socket and connects it to the port specified by remotePort at the host specified by remoteAddress. Binds the socket to the local port specified by localPort at the local host specified by localAddress with a timeout specified by timeout. Throws an IOException if the socket can't be created.

pollingInterval

public static int pollingInterval()

Returns the polling interval in milleseconds. The default polling interval is 100 milliseconds. It can be changed with setPollingInterval. See the "Class Description" section for more information.

setPollingInterval

public static void setPollingInterval(int interval)

Sets the polling interval to interval provided interval is greater than 0. See the "Class Description" section for more information.

© 2001 Apple Computer, Inc. (Last Published April 17, 2001)


Table of Contents