com.caucho.vfs
Class JniSocketImpl

java.lang.Object
  extended by com.caucho.vfs.QSocket
      extended by com.caucho.vfs.JniSocketImpl

@Module
public final class JniSocketImpl
extends QSocket

Abstract socket to handle both normal sockets and bin/resin sockets.


Constructor Summary
JniSocketImpl()
           
 
Method Summary
 void close()
          Closes the socket.
static JniSocketImpl connect(java.lang.String host, int port)
           
 boolean connectImpl(java.lang.String host, int port)
          Creates the new server socket.
protected  void finalize()
           
 int flush()
          Flushes the socket.
 void forceShutdown()
          Closes the socket.
 int getCipherBits()
          Returns the number of bits in the cipher for an ssl connection.
 java.lang.String getCipherSuite()
          Returns the cipher for an ssl connection.
 java.security.cert.X509Certificate getClientCertificate()
          Returns the client certificate.
 long getFd()
           
static java.lang.String getInitMessage()
           
 java.net.InetAddress getLocalAddress()
          Returns the local server's inet address.
 int getLocalAddress(byte[] buffer, int offset, int length)
          Returns the local server's inet address.
 java.lang.String getLocalHost()
          Returns the local server's host name.
 int getLocalPort()
          Returns the server port that accepted the request.
 int getNativeFd()
           
 java.net.InetAddress getRemoteAddress()
          Returns the remote client's inet address.
 int getRemoteAddress(byte[] buffer, int offset, int length)
          Returns the remote client's inet address.
 java.lang.String getRemoteHost()
          Returns the remote client's host name.
 byte[] getRemoteIP()
          Returns the remote client's inet address.
 int getRemotePort()
          Returns the remote client's port.
 StreamImpl getStream()
          Returns a stream impl for the socket encapsulating the input and output stream.
 long getTotalReadBytes()
          Returns the total number of bytes read from the socket connection.
 long getTotalWriteBytes()
          Returns the total number of bytes written to the socket connection.
 boolean isClosed()
          Returns true if closed.
static boolean isEnabled()
           
 boolean isEof()
          Read non-blocking
 boolean isSecure()
          Returns true if the connection is secure.
 int read(byte[] buffer, int offset, int length, long timeout)
          Reads from the socket.
 void setRequestExpireTime(long expireTime)
          Sets the expire time
 void setSecure(boolean isSecure)
          Set true for secure.
 java.lang.String toString()
           
 int write(byte[] buffer, int offset, int length, boolean isEnd)
          Writes to the socket.
 
Methods inherited from class com.caucho.vfs.QSocket
getClientCertificates, getSelectableChannel
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JniSocketImpl

public JniSocketImpl()
Method Detail

isEnabled

public static boolean isEnabled()

getInitMessage

public static java.lang.String getInitMessage()

connect

public static JniSocketImpl connect(java.lang.String host,
                                    int port)
                             throws java.io.IOException
Throws:
java.io.IOException

connectImpl

public boolean connectImpl(java.lang.String host,
                           int port)
                    throws java.io.IOException
Creates the new server socket.

Throws:
java.io.IOException

getFd

public long getFd()

getNativeFd

public int getNativeFd()

getLocalPort

public int getLocalPort()
Returns the server port that accepted the request.

Specified by:
getLocalPort in class QSocket

getRemoteHost

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

Overrides:
getRemoteHost in class QSocket

getRemoteAddress

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

Specified by:
getRemoteAddress in class QSocket

getRemoteAddress

public int getRemoteAddress(byte[] buffer,
                            int offset,
                            int length)
Returns the remote client's inet address.

Overrides:
getRemoteAddress in class QSocket

getRemoteIP

public byte[] getRemoteIP()
Returns the remote client's inet address.

Overrides:
getRemoteIP in class QSocket

getRemotePort

public int getRemotePort()
Returns the remote client's port.

Specified by:
getRemotePort in class QSocket

getLocalHost

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

Overrides:
getLocalHost in class QSocket

getLocalAddress

public java.net.InetAddress getLocalAddress()
Returns the local server's inet address.

Specified by:
getLocalAddress in class QSocket

getLocalAddress

public int getLocalAddress(byte[] buffer,
                           int offset,
                           int length)
Returns the local server's inet address.


setSecure

public void setSecure(boolean isSecure)
Set true for secure.


isSecure

public final boolean isSecure()
Returns true if the connection is secure.

Overrides:
isSecure in class QSocket

getCipherSuite

public java.lang.String getCipherSuite()
Returns the cipher for an ssl connection.

Overrides:
getCipherSuite in class QSocket

getCipherBits

public int getCipherBits()
Returns the number of bits in the cipher for an ssl connection.

Overrides:
getCipherBits in class QSocket

getClientCertificate

public java.security.cert.X509Certificate getClientCertificate()
                                                        throws java.security.cert.CertificateException
Returns the client certificate.

Overrides:
getClientCertificate in class QSocket
Throws:
java.security.cert.CertificateException

setRequestExpireTime

public void setRequestExpireTime(long expireTime)
Sets the expire time

Overrides:
setRequestExpireTime in class QSocket

isEof

public boolean isEof()
Read non-blocking

Overrides:
isEof in class QSocket

read

public int read(byte[] buffer,
                int offset,
                int length,
                long timeout)
         throws java.io.IOException
Reads from the socket.

Throws:
java.io.IOException

write

public int write(byte[] buffer,
                 int offset,
                 int length,
                 boolean isEnd)
          throws java.io.IOException
Writes to the socket.

Throws:
java.io.IOException

flush

public int flush()
          throws java.io.IOException
Flushes the socket.

Throws:
java.io.IOException

getStream

public StreamImpl getStream()
                     throws java.io.IOException
Returns a stream impl for the socket encapsulating the input and output stream.

Specified by:
getStream in class QSocket
Throws:
java.io.IOException

getTotalReadBytes

public long getTotalReadBytes()
Description copied from class: QSocket
Returns the total number of bytes read from the socket connection.

Specified by:
getTotalReadBytes in class QSocket

getTotalWriteBytes

public long getTotalWriteBytes()
Description copied from class: QSocket
Returns the total number of bytes written to the socket connection.

Specified by:
getTotalWriteBytes in class QSocket

isClosed

public boolean isClosed()
Returns true if closed.

Specified by:
isClosed in class QSocket

forceShutdown

public void forceShutdown()
Closes the socket. XXX: potential sync issues

Overrides:
forceShutdown in class QSocket

close

public void close()
           throws java.io.IOException
Closes the socket.

Specified by:
close in class QSocket
Throws:
java.io.IOException

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

toString

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