com.caucho.network.listen
Class TcpSocketLink

java.lang.Object
  extended by com.caucho.network.listen.AbstractSocketLink
      extended by com.caucho.network.listen.TcpSocketLink
All Implemented Interfaces:
SocketLink

@Module
public class TcpSocketLink
extends AbstractSocketLink

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

Each TcpConnection has its own thread.


Method Summary
 void clientDisconnect()
           
 TcpConnectionMXBean getAdmin()
          Returns the admin
 java.lang.String getCipherSuite()
          Returns the cipher suite
 java.security.cert.X509Certificate[] getClientCertificates()
          Returns any client certificates.
 long getConnectionStartTime()
          Returns the time the connection started
static ProtocolConnection getCurrentRequest()
          Returns the ServerRequest for the current thread.
 java.lang.String getDebugId()
           
 java.lang.String getDisplayState()
          Returns the user statistics state
 int getId()
          Returns the connection id.
 long getIdleExpireTime()
          Returns the idle expire time (keepalive or suspend).
 long getIdleStartTime()
          Returns the idle start time (keepalive or suspend)
 long getIdleTimeout()
          The idle time for a keepalive connection
 int getKeySize()
          Returns the key size.
 TcpSocketLinkListener getListener()
          Returns the port which generated the connection.
 java.net.InetAddress getLocalAddress()
          Returns the local address of the socket.
 java.lang.String getLocalHost()
          Returns the local host name.
 int getLocalPort()
          Returns the socket's local TCP port.
 java.lang.String getName()
          Returns the object name for jmx.
 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
 ProtocolConnection getRequest()
          Returns the request for the connection.
 long getRequestStartTime()
          Returns the time the request started
 QSocket getSocket()
          Returns the connection's socket
 com.caucho.network.listen.SocketLinkState getState()
          Returns the state.
 long getThreadId()
          Returns the thread id.
 java.lang.String getVirtualHost()
          Returns the virtual host.
 boolean isActive()
          Returns true for active.
 boolean isAsyncComplete()
           
 boolean isAsyncStarted()
           
 boolean isClosed()
          Returns true for closed.
 boolean isCometActive()
          Returns true for a comet connection
 boolean isCometSuspend()
          Returns true for a comet connection
 boolean isDestroyed()
           
 boolean isDuplex()
          Returns true for a duplex connection
 boolean isIdle()
           
 boolean isKeepaliveAllocated()
           
 boolean isPortActive()
           
 boolean isRequestActive()
          Returns true for active.
 boolean isSecure()
          Returns true if the connection is secure, i.e.
 void killKeepalive(java.lang.String reason)
          Kills the keepalive, so the end of the request is the end of the connection.
 void requestDestroy()
          Destroys the connection()
 void requestShutdownBegin()
           
 void requestShutdownEnd()
           
static void setCurrentRequest(ProtocolConnection request)
          For QA only, set the current request.
 void setIdleTimeout(long idleTimeout)
          Sets the idle time for a keepalive connection.
 SocketLinkDuplexController startDuplex(SocketLinkDuplexListener handler)
          Starts a full duplex (tcp style) request for hmtp/xmpp
 AsyncController toComet(SocketLinkCometListener cometHandler)
          Starts a comet connection.
 java.lang.String toString()
           
 
Methods inherited from class com.caucho.network.listen.AbstractSocketLink
getReadStream, getWriteStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getCurrentRequest

public static ProtocolConnection getCurrentRequest()
Returns the ServerRequest for the current thread.


setCurrentRequest

public static void setCurrentRequest(ProtocolConnection request)
For QA only, set the current request.


getId

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

Specified by:
getId in interface SocketLink
Specified by:
getId in class AbstractSocketLink

getDebugId

public java.lang.String getDebugId()

getName

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


getListener

public TcpSocketLinkListener getListener()
Returns the port which generated the connection.


getRequest

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


getAdmin

public TcpConnectionMXBean getAdmin()
Returns the admin


setIdleTimeout

public void setIdleTimeout(long idleTimeout)
Sets the idle time for a keepalive connection.


getIdleTimeout

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


isPortActive

public boolean isPortActive()

getState

public com.caucho.network.listen.SocketLinkState getState()
Returns the state.

Overrides:
getState in class AbstractSocketLink

isIdle

public final boolean isIdle()

isActive

public boolean isActive()
Returns true for active.


isRequestActive

public boolean isRequestActive()
Returns true for active.


isKeepaliveAllocated

public boolean isKeepaliveAllocated()
Specified by:
isKeepaliveAllocated in interface SocketLink
Overrides:
isKeepaliveAllocated in class AbstractSocketLink

isClosed

public boolean isClosed()
Returns true for closed.


isDestroyed

public final boolean isDestroyed()

isCometActive

public boolean isCometActive()
Description copied from class: AbstractSocketLink
Returns true for a comet connection

Specified by:
isCometActive in interface SocketLink
Overrides:
isCometActive in class AbstractSocketLink

isAsyncStarted

public boolean isAsyncStarted()

isAsyncComplete

public boolean isAsyncComplete()

isCometSuspend

public boolean isCometSuspend()
Description copied from class: AbstractSocketLink
Returns true for a comet connection

Specified by:
isCometSuspend in interface SocketLink
Overrides:
isCometSuspend in class AbstractSocketLink

isDuplex

public boolean isDuplex()
Description copied from class: AbstractSocketLink
Returns true for a duplex connection

Specified by:
isDuplex in interface SocketLink
Overrides:
isDuplex in class AbstractSocketLink

getSocket

public QSocket getSocket()
Returns the connection's socket


getLocalAddress

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

Specified by:
getLocalAddress in interface SocketLink
Specified by:
getLocalAddress in class AbstractSocketLink

getLocalHost

public java.lang.String getLocalHost()
Returns the local host name.

Specified by:
getLocalHost in interface SocketLink
Overrides:
getLocalHost in class AbstractSocketLink

getLocalPort

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

Specified by:
getLocalPort in interface SocketLink
Specified by:
getLocalPort in class AbstractSocketLink

getRemoteAddress

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

Specified by:
getRemoteAddress in interface SocketLink
Specified by:
getRemoteAddress in class AbstractSocketLink

getRemoteHost

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

Specified by:
getRemoteHost in interface SocketLink
Overrides:
getRemoteHost in class AbstractSocketLink

getRemoteAddress

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

Specified by:
getRemoteAddress in interface SocketLink
Overrides:
getRemoteAddress in class AbstractSocketLink

getRemotePort

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

Specified by:
getRemotePort in interface SocketLink
Specified by:
getRemotePort in class AbstractSocketLink

isSecure

public boolean isSecure()
Returns true if the connection is secure, i.e. a SSL connection

Specified by:
isSecure in interface SocketLink
Overrides:
isSecure in class AbstractSocketLink

getVirtualHost

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

Specified by:
getVirtualHost in interface SocketLink
Overrides:
getVirtualHost in class AbstractSocketLink

getCipherSuite

public java.lang.String getCipherSuite()
Returns the cipher suite

Specified by:
getCipherSuite in interface SocketLink
Overrides:
getCipherSuite in class AbstractSocketLink

getKeySize

public int getKeySize()
Returns the key size.

Specified by:
getKeySize in interface SocketLink
Overrides:
getKeySize in class AbstractSocketLink

getClientCertificates

public java.security.cert.X509Certificate[] getClientCertificates()
                                                           throws java.security.cert.CertificateException
Returns any client certificates.

Specified by:
getClientCertificates in interface SocketLink
Overrides:
getClientCertificates in class AbstractSocketLink
Throws:
java.security.cert.CertificateException

getThreadId

public final long getThreadId()
Returns the thread id.


getConnectionStartTime

public final long getConnectionStartTime()
Returns the time the connection started


getRequestStartTime

public final long getRequestStartTime()
Returns the time the request started


getIdleExpireTime

public long getIdleExpireTime()
Returns the idle expire time (keepalive or suspend).


getIdleStartTime

public long getIdleStartTime()
Returns the idle start time (keepalive or suspend)


getDisplayState

public java.lang.String getDisplayState()
Returns the user statistics state


requestDestroy

public final void requestDestroy()
Destroys the connection()


requestShutdownBegin

public void requestShutdownBegin()
Specified by:
requestShutdownBegin in interface SocketLink
Overrides:
requestShutdownBegin in class AbstractSocketLink

requestShutdownEnd

public void requestShutdownEnd()
Specified by:
requestShutdownEnd in interface SocketLink
Overrides:
requestShutdownEnd in class AbstractSocketLink

clientDisconnect

public void clientDisconnect()

killKeepalive

public void killKeepalive(java.lang.String reason)
Kills the keepalive, so the end of the request is the end of the connection.

Specified by:
killKeepalive in interface SocketLink
Overrides:
killKeepalive in class AbstractSocketLink

toComet

public AsyncController toComet(SocketLinkCometListener cometHandler)
Starts a comet connection. Called by the socketLink thread only.

Specified by:
toComet in interface SocketLink
Overrides:
toComet in class AbstractSocketLink

startDuplex

public SocketLinkDuplexController startDuplex(SocketLinkDuplexListener handler)
Starts a full duplex (tcp style) request for hmtp/xmpp


toString

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