Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.go.trove.net
Class LazySocket  view LazySocket download LazySocket.java

java.lang.Object
  extended byjava.net.Socket
      extended bycom.go.trove.net.LazySocket

class LazySocket
extends java.net.Socket

A socket implementation that lazily establishs a connection. It only connects when actually needed. Setting options and getting I/O streams will not force a connection to be established. As soon as a read or write operation is performed, a connection is established.

If the first write operation requires a connection to be established, then a recycled connection is requested. The connection is tested by writing the data to it. If this fails, a new connection is requested and the operation is tried again.

Version:
7 , 00/12/05

Nested Class Summary
private static class LazySocket.Impl
           
 
Field Summary
private  LazySocket.Impl mImpl
           
 
Fields inherited from class java.net.Socket
 
Constructor Summary
private LazySocket(LazySocket.Impl impl)
           
  LazySocket(SocketFactory factory)
           
  LazySocket(SocketFactory factory, long timeout)
           
  LazySocket(SocketFactory factory, java.lang.Object session)
           
  LazySocket(SocketFactory factory, java.lang.Object session, long timeout)
           
 
Method Summary
(package private)  CheckedSocket recycle()
          Returns the internal wrapped socket or null if not connected.
 
Methods inherited from class java.net.Socket
bind, close, connect, connect, getChannel, getInetAddress, getInputStream, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getOutputStream, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown, sendUrgentData, setKeepAlive, setOOBInline, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setSoLinger, setSoTimeout, setTcpNoDelay, setTrafficClass, shutdownInput, shutdownOutput, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mImpl

private final LazySocket.Impl mImpl
Constructor Detail

LazySocket

public LazySocket(SocketFactory factory)
           throws java.net.SocketException

LazySocket

public LazySocket(SocketFactory factory,
                  java.lang.Object session)
           throws java.net.SocketException

LazySocket

public LazySocket(SocketFactory factory,
                  long timeout)
           throws java.net.SocketException

LazySocket

public LazySocket(SocketFactory factory,
                  java.lang.Object session,
                  long timeout)
           throws java.net.SocketException

LazySocket

private LazySocket(LazySocket.Impl impl)
            throws java.net.SocketException
Method Detail

recycle

CheckedSocket recycle()
Returns the internal wrapped socket or null if not connected. After calling recycle, this LazySocket instance is closed.