Class ServConnection

java.lang.Object
  |
  +--ServConnection

public class ServConnection
extends java.lang.Object

A class to handle a connection to an HTTP server.


Field Summary
static int SOCKET_TIMEOUT
           
 
Constructor Summary
ServConnection(java.net.InetAddress ia, int port)
          Create a new ServConnection to the given InetAddress and port.
 
Method Summary
 boolean chunked()
          Is this request chunked?
 void close()
          Close the connection.
 long dataSize()
          Get the size of the data being fetched.
 boolean equals(java.lang.Object o)
          Compare this ServConnection against another object.
 java.io.InputStream getChunkStream()
          Get the last chunked page.
 java.util.Date getInactiveTime()
          Get the time that this ServConnection was Inactive.
 java.net.InetAddress getInetAddress()
          Get the InetAddress that this ServConnection is connected to.
 HTTPInputStream getInputStream()
          Get the InputStream.
 boolean getKeepAlive()
          Get the keepalive value of this ServConnection.
 HTTPOutputStream getOutputStream()
          Get the OutputStream of this ServConnection.
 int getPort()
          Get the port number this ServConnection is connected to.
 void setInactive()
          Mark this ServConnection as Inactive at current time.
 void setInactiveTime(java.util.Date d)
          Mark this ServConnection as Inactive at given time.
 void writeHTTPHeader(HTTPHeader header)
          Write an HTTP header on this connection.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOCKET_TIMEOUT

public static int SOCKET_TIMEOUT
Constructor Detail

ServConnection

public ServConnection(java.net.InetAddress ia,
                      int port)
               throws java.io.IOException
Create a new ServConnection to the given InetAddress and port.
Parameters:
InetAddress - theserver to connect to.
port - the port number to connect to.
Method Detail

close

public void close()
Close the connection.

getInetAddress

public java.net.InetAddress getInetAddress()
Get the InetAddress that this ServConnection is connected to.
Returns:
the InetAddress.

getPort

public int getPort()
Get the port number this ServConnection is connected to.
Returns:
the port number.

setInactive

public void setInactive()
Mark this ServConnection as Inactive at current time.

setInactiveTime

public void setInactiveTime(java.util.Date d)
Mark this ServConnection as Inactive at given time.
Parameters:
d - the time that this ServConnection is Inactive.

getInactiveTime

public java.util.Date getInactiveTime()
Get the time that this ServConnection was Inactive.

getInputStream

public HTTPInputStream getInputStream()
Get the InputStream.
Returns:
an HTTPInputStream.

getOutputStream

public HTTPOutputStream getOutputStream()
Get the OutputStream of this ServConnection.
Returns:
an HTTPOutputStream.

getKeepAlive

public boolean getKeepAlive()
Get the keepalive value of this ServConnection.
Returns:
true if this ServConnection may be reused.

dataSize

public long dataSize()
Get the size of the data being fetched.
Returns:
the number of bytes of the page or -1 if unknown.

chunked

public boolean chunked()
Is this request chunked?
Returns:
true if the last read request was chunked, false otherwise.

getChunkStream

public java.io.InputStream getChunkStream()
Get the last chunked page.
Returns:
an InputStream to the last chunked page.

writeHTTPHeader

public void writeHTTPHeader(HTTPHeader header)
                     throws java.io.IOException
Write an HTTP header on this connection.
Parameters:
header - the Header to write.

equals

public boolean equals(java.lang.Object o)
Compare this ServConnection against another object.
Overrides:
equals in class java.lang.Object
Parameters:
o - the Object to compare against.
Returns:
true if the other Object is a ServConnection connected to the same InetAddress and port, false otherwise.