com.caucho.server.port
Class TcpConnection

java.lang.Object
  extended by com.caucho.server.connection.Connection
      extended by com.caucho.server.port.TcpConnection

public class TcpConnection
extends Connection

A protocol-independent TcpConnection. TcpConnection controls the TCP Socket and provides buffered streams.

Each TcpConnection has its own thread.


Field Summary
 boolean _isFree
           
 
Fields inherited from class com.caucho.server.connection.Connection
_controller
 
Method Summary
 long beginActive()
          Begins an active connection.
 void clearKeepalive()
          Sets the keepalive state.
 void close()
           
protected  void closeControllerImpl()
          Closes the controller.
 void closeOnShutdown()
          Closes on shutdown.
protected  java.lang.String dbgId()
           
 void destroy()
          Destroys the connection()
 void endActive()
          Ends an active connection.
 long getAccessTime()
          Returns the time the last Request began in milliseconds.
 int getId()
          Returns the connection id.
 long getIdleTimeMax()
          The idle time for a keepalive connection
 long getKeepaliveExpireTime()
          Returns the keepalive expire time.
 long getKeepaliveStartTime()
          Returns the keepalive start time
 java.net.InetAddress getLocalAddress()
          Returns the local address of the socket.
 int getLocalPort()
          Returns the socket's local TCP port.
 java.lang.String getName()
          Returns the object name for jmx.
 Port getPort()
          Returns the port which generated the connection.
 java.lang.Runnable getReadTask()
          Returns the current read task
 java.net.InetAddress getRemoteAddress()
          Returns the socket's remote address.
 int getRemoteAddress(byte[] buffer, int offset, int length)
          Adds from the socket's remote address.
 java.lang.String getRemoteHost()
          Returns the socket's remote host name.
 int getRemotePort()
          Returns the socket's remote port
 ServerRequest getRequest()
          Returns the request for the connection.
 long getRequestActiveTime()
          Returns the time the current request has taken.
 long getRequestStartTime()
           
 java.lang.Runnable getResumeTask()
          Returns the current write task
 QSocket getSocket()
          Returns the connection's socket
 java.lang.Exception getStartThread()
           
 java.lang.String getState()
          Returns the state string.
 long getSuspendTime()
          Returns the time the comet suspend started
 long getThreadId()
          Returns the thread id.
 java.lang.String getVirtualHost()
          Returns the virtual host.
 void initSocket()
          Initialize the socket for a new connection
 boolean isActive()
          Returns true for active.
 boolean isClosed()
          Returns true for closed.
 boolean isRequestActive()
          Returns true for active.
 boolean isSecure()
          Returns true if secure (ssl)
 void setAccessTime(long now)
          Sets the time of the request start.
 void setController(ConnectionController controller)
          Sets controller
 void setIdleTimeMax(long idleTime)
          Sets the idle time for a keepalive connection.
 void setKeepalive()
          Sets the keepalive state.
 void setRequest(ServerRequest request)
          Sets the connection's request.
 void setStartThread()
           
 void start()
          Starts the connection.
 QSocket startSocket()
          Returns the connection's socket
 boolean toKeepalive()
           
 java.lang.String toString()
           
protected  boolean wake()
          Wakes the connection (comet-style).
 
Methods inherited from class com.caucho.server.connection.Connection
getController, getReadStream, getWriteStream, sendBroadcast
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_isFree

public boolean _isFree
Method Detail

setStartThread

public void setStartThread()

getStartThread

public java.lang.Exception getStartThread()

setAccessTime

public void setAccessTime(long now)
Sets the time of the request start. ServerRequests can use setAccessTime() to put off connection reaping. HttpRequest calls setAccessTime() at the beginning of each request.

Parameters:
now - the current time in milliseconds as by Alarm.getCurrentTime().

getAccessTime

public long getAccessTime()
Returns the time the last Request began in milliseconds.


isActive

public boolean isActive()
Returns true for active.


isRequestActive

public boolean isRequestActive()
Returns true for active.


getId

public int getId()
Returns the connection id. Primarily for debugging.

Specified by:
getId in class Connection

isClosed

public boolean isClosed()
Returns true for closed.


setIdleTimeMax

public void setIdleTimeMax(long idleTime)
Sets the idle time for a keepalive connection.


getIdleTimeMax

public long getIdleTimeMax()
The idle time for a keepalive connection


setKeepalive

public void setKeepalive()
Sets the keepalive state. Called only by the SelectManager and Port.


clearKeepalive

public void clearKeepalive()
Sets the keepalive state. Called only by the SelectManager and Port.


getKeepaliveExpireTime

public long getKeepaliveExpireTime()
Returns the keepalive expire time.


getKeepaliveStartTime

public long getKeepaliveStartTime()
Returns the keepalive start time


getName

public java.lang.String getName()
Returns the object name for jmx.


getPort

public Port getPort()
Returns the port which generated the connection.


getReadTask

public java.lang.Runnable getReadTask()
Returns the current read task


getResumeTask

public java.lang.Runnable getResumeTask()
Returns the current write task


getRequest

public final ServerRequest getRequest()
Returns the request for the connection.


setRequest

public final void setRequest(ServerRequest request)
Sets the connection's request.


isSecure

public boolean isSecure()
Description copied from class: Connection
Returns true if secure (ssl)

Overrides:
isSecure in class Connection

getSocket

public QSocket getSocket()
Returns the connection's socket


getSuspendTime

public long getSuspendTime()
Returns the time the comet suspend started


initSocket

public void initSocket()
                throws java.io.IOException
Initialize the socket for a new connection

Throws:
java.io.IOException

startSocket

public QSocket startSocket()
Returns the connection's socket


getLocalAddress

public java.net.InetAddress getLocalAddress()
Returns the local address of the socket.

Specified by:
getLocalAddress in class Connection

getLocalPort

public int getLocalPort()
Returns the socket's local TCP port.

Specified by:
getLocalPort in class Connection

getRemoteAddress

public java.net.InetAddress getRemoteAddress()
Returns the socket's remote address.

Specified by:
getRemoteAddress in class Connection

getRemoteHost

public java.lang.String getRemoteHost()
Returns the socket's remote host name.

Overrides:
getRemoteHost in class Connection

getRemoteAddress

public int getRemoteAddress(byte[] buffer,
                            int offset,
                            int length)
Adds from the socket's remote address.

Overrides:
getRemoteAddress in class Connection

getRemotePort

public int getRemotePort()
Returns the socket's remote port

Specified by:
getRemotePort in class Connection

getState

public final java.lang.String getState()
Returns the state string.


getVirtualHost

public java.lang.String getVirtualHost()
Returns the virtual host.

Overrides:
getVirtualHost in class Connection

getThreadId

public final long getThreadId()
Returns the thread id.


getRequestActiveTime

public final long getRequestActiveTime()
Returns the time the current request has taken.


beginActive

public final long beginActive()
Begins an active connection.


getRequestStartTime

public final long getRequestStartTime()

endActive

public final void endActive()
Ends an active connection.


toKeepalive

public boolean toKeepalive()

start

public void start()
Starts the connection.


setController

public void setController(ConnectionController controller)
Sets controller

Overrides:
setController in class Connection

wake

protected boolean wake()
Wakes the connection (comet-style).

Overrides:
wake in class Connection

closeOnShutdown

public void closeOnShutdown()
Closes on shutdown.


close

public void close()

closeControllerImpl

protected void closeControllerImpl()
Closes the controller.

Overrides:
closeControllerImpl in class Connection

destroy

public final void destroy()
Destroys the connection()


dbgId

protected java.lang.String dbgId()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object