rabbit.io
Class WebConnection

java.lang.Object
  extended by rabbit.io.WebConnection
All Implemented Interfaces:
Closeable

public class WebConnection
extends Object
implements Closeable

A class to handle a connection to the Internet.

Author:
Robert Olofsson

Constructor Summary
WebConnection(Address address, SocketBinder binder, Counter counter)
          Create a new WebConnection to the given InetAddress and port.
 
Method Summary
 void close()
           
 void connect(NioHandler nioHandler, WebConnectionListener wcl)
           
 Address getAddress()
           
 SocketChannel getChannel()
           
 boolean getKeepalive()
          Get the keepalive value of this WebConnection.
 long getReleasedAt()
          Get the time that this WebConnection was released.
 boolean mayPipeline()
          Check if this WebConnection may be used for pipelining.
 void setKeepalive(boolean b)
          Set the keepalive value for this WebConnection, Can only be turned off.
 void setMayPipeline(boolean b)
          Mark this WebConnection for pipelining.
 void setReleased()
          Mark this WebConnection as released at current time.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebConnection

public WebConnection(Address address,
                     SocketBinder binder,
                     Counter counter)
Create a new WebConnection to the given InetAddress and port.

Parameters:
address - the computer to connect to.
counter - the Counter to used to collect statistics
Method Detail

toString

public String toString()
Overrides:
toString in class Object

getAddress

public Address getAddress()

getChannel

public SocketChannel getChannel()

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException

connect

public void connect(NioHandler nioHandler,
                    WebConnectionListener wcl)
             throws IOException
Throws:
IOException

setKeepalive

public void setKeepalive(boolean b)
Set the keepalive value for this WebConnection, Can only be turned off.

Parameters:
b - the new keepalive value.

getKeepalive

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

Returns:
true if this WebConnection may be reused.

setReleased

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


getReleasedAt

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


setMayPipeline

public void setMayPipeline(boolean b)
Mark this WebConnection for pipelining.


mayPipeline

public boolean mayPipeline()
Check if this WebConnection may be used for pipelining.