Secure iNet Factory

com.jscape.inet.util
Class TimedSocket

java.lang.Object
  extended by com.jscape.inet.util.TimedSocket

public class TimedSocket
extends java.lang.Object

Implements methods for creating sockets within a defined timeout.

Timeout is based upon time to establish connection, as well as reading blocking I/O data from the incoming socket connection.

Example Usage:

 String hostname = "www.myserver.com";
 int port = 80;
 int timeout = 5000; // 5 seconds
 try
 {
   Socket con = TimedSocket.getSocket(hostname,port,timeout);
 }
 catch(Exception ioe)
 {
   // handle exception
 }
 


Method Summary
static java.net.Socket getSocket(java.net.InetAddress addr, int port, java.net.InetAddress localAddr, int localPort, long delay)
          Creates a new Socket instance.
static java.net.Socket getSocket(java.net.InetAddress addr, int port, java.net.InetAddress localAddr, int localPort, long delay, int sendBuffer, int receiveBuffer)
          Creates a new Socket instance.
static java.net.Socket getSocket(java.net.InetAddress addr, int port, long delay)
          Creates a new Socket instance.
static java.net.Socket getSocket(java.net.InetAddress addr, int port, long delay, int sendBuffer, int receiveBuffer)
          Creates a new Socket instance.
static java.net.Socket getSocket(java.lang.String host, int port, long delay)
          Creates a new Socket instance.
static java.net.Socket getSocket(java.lang.String host, int port, long delay, int sendBuffer, int receiveBuffer)
          Creates a new Socket instance.
static java.net.Socket getSocket(java.lang.String host, int port, long delay, java.lang.String proxyHost, int proxyPort, java.lang.String proxyUsername, java.lang.String proxyPassword, java.lang.String proxyType)
          Creates a new Socket instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSocket

public static java.net.Socket getSocket(java.net.InetAddress addr,
                                        int port,
                                        java.net.InetAddress localAddr,
                                        int localPort,
                                        long delay)
                                 throws java.io.IOException
Creates a new Socket instance.

Parameters:
addr - the InetAddress to connect to
port - the port to connect to
localAddr - the local InetAddress to connect from
localPort - the local port to connect from
delay - timeout in milliseconds
Returns:
a Socket
Throws:
java.io.IOException - timeout is reached or other I/O error occurs

getSocket

public static java.net.Socket getSocket(java.net.InetAddress addr,
                                        int port,
                                        java.net.InetAddress localAddr,
                                        int localPort,
                                        long delay,
                                        int sendBuffer,
                                        int receiveBuffer)
                                 throws java.io.IOException
Creates a new Socket instance.

Parameters:
addr - the InetAddress to connect to
port - the port to connect to
localAddr - the local InetAddress to connect from
localPort - the local port to connect from
delay - timeout in milliseconds
sendBuffer - Send socket buffer value.
receiveBuffer - Receive socket buffer value
Returns:
a Socket
Throws:
java.io.IOException - timeout is reached or other I/O error occurs

getSocket

public static java.net.Socket getSocket(java.net.InetAddress addr,
                                        int port,
                                        long delay)
                                 throws java.io.IOException
Creates a new Socket instance.

Parameters:
addr - the InetAddress to connect to
port - the port to connect to
delay - timeout in milliseconds
Returns:
a Socket
Throws:
java.io.IOException - timeout is reached or other I/O error occurs

getSocket

public static java.net.Socket getSocket(java.net.InetAddress addr,
                                        int port,
                                        long delay,
                                        int sendBuffer,
                                        int receiveBuffer)
                                 throws java.io.IOException
Creates a new Socket instance.

Parameters:
addr - the InetAddress to connect to
port - the port to connect to
delay - timeout in milliseconds
Returns:
a Socket
Throws:
java.io.IOException - timeout is reached or other I/O error occurs

getSocket

public static java.net.Socket getSocket(java.lang.String host,
                                        int port,
                                        long delay,
                                        java.lang.String proxyHost,
                                        int proxyPort,
                                        java.lang.String proxyUsername,
                                        java.lang.String proxyPassword,
                                        java.lang.String proxyType)
                                 throws java.io.IOException
Creates a new Socket instance.

Parameters:
host - the host to connect to
port - the port to connect to
delay - timeout in milliseconds
proxyHost - the proxy host to connect through
proxyPort - the proxy port to connect on
proxyUsername - The username to use
proxyPassword - The proxy password to use
proxyType - either HTTP or SOCKS5
Returns:
a new Socket instance
Throws:
java.io.IOException - timeout is reached or other I/O error occurs

getSocket

public static java.net.Socket getSocket(java.lang.String host,
                                        int port,
                                        long delay)
                                 throws java.io.IOException
Creates a new Socket instance.

Parameters:
host - the host to connect to
port - the port to connect to
delay - timeout in milliseconds
Returns:
a Socket
Throws:
java.io.IOException - timeout is reached or other I/O error occurs

getSocket

public static java.net.Socket getSocket(java.lang.String host,
                                        int port,
                                        long delay,
                                        int sendBuffer,
                                        int receiveBuffer)
                                 throws java.io.IOException
Creates a new Socket instance.

Parameters:
host - the host to connect to
port - the port to connect to
delay - timeout in milliseconds
Returns:
a Socket
Throws:
java.io.IOException - timeout is reached or other I/O error occurs

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved