org.scache
Class WebConnection

java.lang.Object
  extended byorg.scache.WebConnection

public class WebConnection
extends java.lang.Object

A class to handle a open connection to the Internet.


Field Summary
 java.net.InetAddress ia
           
 boolean keepalive
           
 int port
           
 long releasedAt
           
 java.net.Socket socket
           
 java.io.DataInputStream webis
           
 java.io.DataOutputStream webos
           
 
Constructor Summary
WebConnection(java.io.DataInputStream is)
           
WebConnection(java.net.InetAddress ia, int port)
          Create a new WebConnection to the given InetAddress and port.
 
Method Summary
 void close()
          Close the connection.
 java.net.InetAddress getInetAddress()
          Get the InetAddress that this WebConnection is connected to.
 java.io.DataInputStream getInputStream()
          Get the InputStream.
 boolean getKeepAlive()
          Get the keepalive value of this WebConnection.
 java.io.DataOutputStream getOutputStream()
          Get the OutputStream of this WebConnection.
 int getPort()
          Get the port number this WebConnection is connected to.
 long getReleasedAt()
          Get the time that this WebConnection was released.
 void reconnect()
           
 void setKeepAlive(boolean ka)
           
 void setReleased()
          Mark this WebConnection as released at current time.
 void setReleased(long d)
          Mark this WebConnection as released at given time.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

socket

public java.net.Socket socket

webis

public java.io.DataInputStream webis

webos

public java.io.DataOutputStream webos

ia

public java.net.InetAddress ia

port

public int port

releasedAt

public long releasedAt

keepalive

public boolean keepalive
Constructor Detail

WebConnection

public WebConnection(java.net.InetAddress ia,
                     int port)
              throws java.io.IOException
Create a new WebConnection to the given InetAddress and port.

Parameters:
port - the port number to connect to.

WebConnection

public WebConnection(java.io.DataInputStream is)
Method Detail

reconnect

public void reconnect()
               throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Close the connection.

Throws:
java.io.IOException

getInetAddress

public java.net.InetAddress getInetAddress()
Get the InetAddress that this WebConnection is connected to.

Returns:
the InetAddress.

getPort

public int getPort()
Get the port number this WebConnection is connected to.

Returns:
the port number.

setReleased

public void setReleased()
Mark this WebConnection as released at current time.


setReleased

public void setReleased(long d)
Mark this WebConnection as released at given time.

Parameters:
d - the time that this WebConnection is released.

getReleasedAt

public long getReleasedAt()
Get the time that this WebConnection was released.


getInputStream

public java.io.DataInputStream getInputStream()
Get the InputStream.

Returns:
an DataInputStream.

getOutputStream

public java.io.DataOutputStream getOutputStream()
Get the OutputStream of this WebConnection.

Returns:
an DataOutputStream.

getKeepAlive

public boolean getKeepAlive()
Get the keepalive value of this WebConnection.

Returns:
true if this WebConnection may be reused.

setKeepAlive

public void setKeepAlive(boolean ka)

toString

public java.lang.String toString()