org.jboss.remoting.transport.multiplex
Class VirtualSocket

java.lang.Object
  extended by java.net.Socket
      extended by org.jboss.remoting.transport.multiplex.VirtualSocket

public class VirtualSocket
extends java.net.Socket

VirtualSocket represents an endpoint on a virtual connection created by the Multiplex system. It extends java.net.Socket and reimplements nearly all of the methods in java.net.Socket. For information about method behavior, please see the java.net.Socket javadoc. For more information about the nature of virtual sockets, please see the Multiplex documentation at the labs.jboss.org web site.

Copyright (c) 2005

Author:
Ron Sigal

Nested Class Summary
static interface VirtualSocket.DisconnectListener
          A class that implements DisconnectListener can register to be notified if the remote peer of this VirtualSocket has disconnected.
protected  class VirtualSocket.PendingClose
           
protected  class VirtualSocket.PendingRemoteDisconnect
           
 
Field Summary
protected static java.lang.Thread closingThread
           
protected static org.jboss.logging.Logger log
           
 
Constructor Summary
VirtualSocket()
          See superclass javadoc.
VirtualSocket(java.net.InetAddress address, int port)
          See superclass javadoc.
VirtualSocket(java.net.InetAddress host, int port, boolean stream)
          See superclass javadoc.
VirtualSocket(java.net.InetAddress address, int port, java.net.InetAddress localAddr, int localPort)
          See superclass javadoc.
VirtualSocket(java.util.Map configuration)
           
VirtualSocket(MultiplexingManager manager, SocketId remoteSocketId, java.util.Map configuration)
           
VirtualSocket(java.net.SocketImpl impl)
          This constuctor is not implemented.
VirtualSocket(java.lang.String host, int port)
          See superclass javadoc.
VirtualSocket(java.lang.String host, int port, boolean stream)
          See superclass javadoc.
VirtualSocket(java.lang.String host, int port, java.net.InetAddress localAddr, int localPort)
          See superclass javadoc.
 
Method Summary
 void addDisconnectListener(VirtualSocket.DisconnectListener listener)
           
 void bind(java.net.SocketAddress address)
          See superclass javadoc.
 void close()
          See superclass javadoc.
 void connect(java.net.SocketAddress socketAddress)
          See superclass javadoc.
 void connect(java.net.SocketAddress socketAddress, int timeout)
          See superclass javadoc.
 void connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, int timeout)
           
protected  void doClose()
           
protected  java.net.Socket getActualSocket()
           
 java.nio.channels.SocketChannel getChannel()
          See superclass javadoc.
 java.net.InetAddress getInetAddress()
          See superclass javadoc.
 java.io.InputStream getInputStream()
          See superclass javadoc.
 boolean getKeepAlive()
          See superclass javadoc.
 java.net.InetAddress getLocalAddress()
          See superclass javadoc.
 int getLocalPort()
          See superclass javadoc.
 java.net.SocketAddress getLocalSocketAddress()
          See superclass javadoc.
 SocketId getLocalSocketId()
           
 int getLocalVirtualPort()
           
protected  MultiplexingManager getManager()
           
 MultiplexingManager getMultiplexingManager()
           
 boolean getOOBInline()
          See superclass javadoc.
 java.io.OutputStream getOutputStream()
          See superclass javadoc.
 int getPort()
          See superclass javadoc.
protected  Protocol getProtocol()
           
 java.net.Socket getRealSocket()
           
 int getReceiveBufferSize()
          See superclass javadoc.
 java.net.SocketAddress getRemoteSocketAddress()
          See superclass javadoc.
 SocketId getRemoteSocketId()
           
 boolean getReuseAddress()
          See superclass javadoc.
 int getSendBufferSize()
          See superclass javadoc.
 int getSoLinger()
          See superclass javadoc.
 int getSoTimeout()
          See superclass javadoc.
 boolean getTcpNoDelay()
          See superclass javadoc.
 int getTrafficClass()
          See superclass javadoc.
 int getVirtualPort()
           
protected  void handleRemoteDisconnect()
           
protected  void handleRemoteOutputShutDown()
           
protected  boolean hasReceivedDisconnectMessage()
           
 boolean isBound()
          See superclass javadoc.
 boolean isClosed()
          See superclass javadoc.
 boolean isConnected()
          See superclass javadoc.
 boolean isFunctional()
          Returns true if and only if has not received notification of error state on actual connection.
 boolean isInputShutdown()
          See superclass javadoc.
 boolean isOutputShutdown()
          See superclass javadoc.
protected  void notifyOfException()
          Indicate error condition on actual connection.
 void removeDisconnectListener(VirtualSocket.DisconnectListener listener)
           
 void sendUrgentData(int data)
          This method is not implemented.
protected  void setActualSocket(java.net.Socket actualSocket)
           
protected  void setBound(boolean bound)
           
protected  void setClosed(boolean closed)
           
 void setConfiguration(java.util.Map configuration)
           
protected  void setConnected(boolean connected)
           
protected  void setInputShutdown(boolean inputShutdown)
           
protected  void setInputStream(MultiplexingInputStream inputStream)
           
 void setKeepAlive(boolean on)
          See superclass javadoc.
protected  void setLocalSocketId(SocketId localSocketId)
           
protected  void setManager(MultiplexingManager manager)
           
 void setOOBInline(boolean on)
           
protected  void setOutputShutdown(boolean outputShutdown)
           
protected  void setOutputStream(MultiplexingOutputStream outputStream)
           
protected  void setProtocol(Protocol protocol)
           
 void setReceiveBufferSize(int size)
          See superclass javadoc.
protected  void setReceivedDisconnectMessage(boolean receivedDisconnectMessage)
           
protected  void setRemoteSocketId(SocketId remoteSocketId)
           
 void setReuseAddress(boolean on)
          See superclass javadoc.
 void setSendBufferSize(int size)
          See superclass javadoc.
 void setSoLinger(boolean on, int linger)
          See superclass javadoc.
 void setSoTimeout(int timeout)
          See superclass javadoc.
 void setTcpNoDelay(boolean on)
          See superclass javadoc.
 void setTrafficClass(int tc)
          See superclass javadoc.
 void shutdownInput()
          See superclass javadoc.
 void shutdownOutput()
          See superclass javadoc.
 java.lang.String toString()
          See superclass javadoc.
 
Methods inherited from class java.net.Socket
setPerformancePreferences, setSocketImplFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final org.jboss.logging.Logger log

closingThread

protected static java.lang.Thread closingThread
Constructor Detail

VirtualSocket

public VirtualSocket(MultiplexingManager manager,
                     SocketId remoteSocketId,
                     java.util.Map configuration)
              throws java.io.IOException
Throws:
java.io.IOException

VirtualSocket

public VirtualSocket(java.util.Map configuration)

VirtualSocket

public VirtualSocket()
See superclass javadoc.


VirtualSocket

public VirtualSocket(java.lang.String host,
                     int port)
              throws java.net.UnknownHostException,
                     java.io.IOException
See superclass javadoc.

Throws:
java.net.UnknownHostException
java.io.IOException

VirtualSocket

public VirtualSocket(java.lang.String host,
                     int port,
                     boolean stream)
              throws java.io.IOException
See superclass javadoc.

Parameters:
host -
port -
stream -
Throws:
java.io.IOException

VirtualSocket

public VirtualSocket(java.net.InetAddress address,
                     int port)
              throws java.io.IOException
See superclass javadoc.

Parameters:
address -
port -
Throws:
java.io.IOException

VirtualSocket

public VirtualSocket(java.net.InetAddress host,
                     int port,
                     boolean stream)
              throws java.io.IOException
See superclass javadoc.

Parameters:
host -
port -
stream -
Throws:
java.io.IOException

VirtualSocket

public VirtualSocket(java.net.SocketImpl impl)
              throws java.net.SocketException
This constuctor is not implemented.

Parameters:
impl -
Throws:
java.net.SocketException - in all cases

VirtualSocket

public VirtualSocket(java.lang.String host,
                     int port,
                     java.net.InetAddress localAddr,
                     int localPort)
              throws java.io.IOException
See superclass javadoc.

Parameters:
host -
port -
localAddr -
localPort -
Throws:
java.io.IOException

VirtualSocket

public VirtualSocket(java.net.InetAddress address,
                     int port,
                     java.net.InetAddress localAddr,
                     int localPort)
              throws java.io.IOException
See superclass javadoc.

Parameters:
address -
port -
localAddr -
localPort -
Throws:
java.io.IOException
Method Detail

bind

public void bind(java.net.SocketAddress address)
          throws java.io.IOException
See superclass javadoc.

Overrides:
bind in class java.net.Socket
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
See superclass javadoc.

Overrides:
close in class java.net.Socket
Throws:
java.io.IOException

connect

public void connect(java.net.SocketAddress socketAddress)
             throws java.io.IOException
See superclass javadoc.

Overrides:
connect in class java.net.Socket
Throws:
java.io.IOException

connect

public void connect(java.net.SocketAddress socketAddress,
                    int timeout)
             throws java.io.IOException
See superclass javadoc.

Overrides:
connect in class java.net.Socket
Throws:
java.io.IOException

getChannel

public java.nio.channels.SocketChannel getChannel()
See superclass javadoc.

Overrides:
getChannel in class java.net.Socket

getInetAddress

public java.net.InetAddress getInetAddress()
See superclass javadoc.

Overrides:
getInetAddress in class java.net.Socket

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
See superclass javadoc.

Overrides:
getInputStream in class java.net.Socket
Throws:
java.io.IOException

getKeepAlive

public boolean getKeepAlive()
                     throws java.net.SocketException
See superclass javadoc.

Overrides:
getKeepAlive in class java.net.Socket
Throws:
java.net.SocketException

getLocalAddress

public java.net.InetAddress getLocalAddress()
See superclass javadoc. Note. Socket.getLocalAddress() returns "wildcard" address for an unbound socket.

Overrides:
getLocalAddress in class java.net.Socket

getLocalPort

public int getLocalPort()
See superclass javadoc.

Overrides:
getLocalPort in class java.net.Socket

getLocalSocketAddress

public java.net.SocketAddress getLocalSocketAddress()
See superclass javadoc.

Overrides:
getLocalSocketAddress in class java.net.Socket

getOOBInline

public boolean getOOBInline()
                     throws java.net.SocketException
See superclass javadoc.

Overrides:
getOOBInline in class java.net.Socket
Throws:
java.net.SocketException

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
See superclass javadoc.

Overrides:
getOutputStream in class java.net.Socket
Throws:
java.io.IOException

getPort

public int getPort()
See superclass javadoc.

Overrides:
getPort in class java.net.Socket

getReceiveBufferSize

public int getReceiveBufferSize()
                         throws java.net.SocketException
See superclass javadoc.

Overrides:
getReceiveBufferSize in class java.net.Socket
Throws:
java.net.SocketException

getRemoteSocketAddress

public java.net.SocketAddress getRemoteSocketAddress()
See superclass javadoc.

Overrides:
getRemoteSocketAddress in class java.net.Socket

getReuseAddress

public boolean getReuseAddress()
                        throws java.net.SocketException
See superclass javadoc.

Overrides:
getReuseAddress in class java.net.Socket
Throws:
java.net.SocketException

getSendBufferSize

public int getSendBufferSize()
                      throws java.net.SocketException
See superclass javadoc.

Overrides:
getSendBufferSize in class java.net.Socket
Throws:
java.net.SocketException

getSoLinger

public int getSoLinger()
                throws java.net.SocketException
See superclass javadoc.

Overrides:
getSoLinger in class java.net.Socket
Throws:
java.net.SocketException

getSoTimeout

public int getSoTimeout()
                 throws java.net.SocketException
See superclass javadoc.

Overrides:
getSoTimeout in class java.net.Socket
Throws:
java.net.SocketException

getTcpNoDelay

public boolean getTcpNoDelay()
                      throws java.net.SocketException
See superclass javadoc.

Overrides:
getTcpNoDelay in class java.net.Socket
Throws:
java.net.SocketException

getTrafficClass

public int getTrafficClass()
                    throws java.net.SocketException
See superclass javadoc.

Overrides:
getTrafficClass in class java.net.Socket
Throws:
java.net.SocketException

isBound

public boolean isBound()
See superclass javadoc.

Overrides:
isBound in class java.net.Socket

isClosed

public boolean isClosed()
See superclass javadoc.

Overrides:
isClosed in class java.net.Socket

isConnected

public boolean isConnected()
See superclass javadoc.

Overrides:
isConnected in class java.net.Socket

isInputShutdown

public boolean isInputShutdown()
See superclass javadoc.

Overrides:
isInputShutdown in class java.net.Socket

isOutputShutdown

public boolean isOutputShutdown()
See superclass javadoc.

Overrides:
isOutputShutdown in class java.net.Socket

sendUrgentData

public void sendUrgentData(int data)
                    throws java.io.IOException
This method is not implemented.

See superclass javadoc.

Overrides:
sendUrgentData in class java.net.Socket
Throws:
java.io.IOException

setKeepAlive

public void setKeepAlive(boolean on)
                  throws java.net.SocketException
See superclass javadoc.

Overrides:
setKeepAlive in class java.net.Socket
Throws:
java.net.SocketException

setOOBInline

public void setOOBInline(boolean on)
                  throws java.net.SocketException
Overrides:
setOOBInline in class java.net.Socket
Throws:
java.net.SocketException

setReceiveBufferSize

public void setReceiveBufferSize(int size)
                          throws java.net.SocketException
See superclass javadoc.

Overrides:
setReceiveBufferSize in class java.net.Socket
Throws:
java.net.SocketException

setReuseAddress

public void setReuseAddress(boolean on)
                     throws java.net.SocketException
See superclass javadoc.

Overrides:
setReuseAddress in class java.net.Socket
Throws:
java.net.SocketException

setSendBufferSize

public void setSendBufferSize(int size)
                       throws java.net.SocketException
See superclass javadoc.

Overrides:
setSendBufferSize in class java.net.Socket
Throws:
java.net.SocketException

setSoLinger

public void setSoLinger(boolean on,
                        int linger)
                 throws java.net.SocketException
See superclass javadoc.

Overrides:
setSoLinger in class java.net.Socket
Throws:
java.net.SocketException

setSoTimeout

public void setSoTimeout(int timeout)
                  throws java.net.SocketException
See superclass javadoc.

Overrides:
setSoTimeout in class java.net.Socket
Throws:
java.net.SocketException

setTcpNoDelay

public void setTcpNoDelay(boolean on)
                   throws java.net.SocketException
See superclass javadoc.

Overrides:
setTcpNoDelay in class java.net.Socket
Throws:
java.net.SocketException

setTrafficClass

public void setTrafficClass(int tc)
                     throws java.net.SocketException
See superclass javadoc.

Overrides:
setTrafficClass in class java.net.Socket
Throws:
java.net.SocketException

shutdownInput

public void shutdownInput()
                   throws java.io.IOException
See superclass javadoc.

Overrides:
shutdownInput in class java.net.Socket
Throws:
java.io.IOException

shutdownOutput

public void shutdownOutput()
                    throws java.io.IOException
See superclass javadoc.

Overrides:
shutdownOutput in class java.net.Socket
Throws:
java.io.IOException

toString

public java.lang.String toString()
See superclass javadoc.

Overrides:
toString in class java.net.Socket

addDisconnectListener

public void addDisconnectListener(VirtualSocket.DisconnectListener listener)

connect

public void connect(java.net.SocketAddress remoteAddress,
                    java.net.SocketAddress localAddress,
                    int timeout)
             throws java.io.IOException
Throws:
java.io.IOException

getMultiplexingManager

public MultiplexingManager getMultiplexingManager()

getVirtualPort

public int getVirtualPort()

getLocalVirtualPort

public int getLocalVirtualPort()

getLocalSocketId

public SocketId getLocalSocketId()
Returns:

getRealSocket

public java.net.Socket getRealSocket()
Returns:

getRemoteSocketId

public SocketId getRemoteSocketId()
Returns:

isFunctional

public boolean isFunctional()
Returns true if and only if has not received notification of error state on actual connection.

Returns:
true if and only if has not received notification of error state on actual connection

removeDisconnectListener

public void removeDisconnectListener(VirtualSocket.DisconnectListener listener)
Parameters:
listener -

setConfiguration

public void setConfiguration(java.util.Map configuration)
Parameters:
configuration -

getActualSocket

protected java.net.Socket getActualSocket()
Returns:
Returns the actualSocket.

setActualSocket

protected void setActualSocket(java.net.Socket actualSocket)
Parameters:
actualSocket - The actualSocket to set.

setBound

protected void setBound(boolean bound)
Parameters:
bound - The bound to set.

setClosed

protected void setClosed(boolean closed)
Parameters:
closed - The closed to set.

setConnected

protected void setConnected(boolean connected)
Parameters:
connected - The connected to set.

setInputShutdown

protected void setInputShutdown(boolean inputShutdown)
Parameters:
inputShutdown - The inputShutdown to set.

setInputStream

protected void setInputStream(MultiplexingInputStream inputStream)
Parameters:
inputStream - The inputStream to set.

setLocalSocketId

protected void setLocalSocketId(SocketId localSocketId)
Parameters:
localSocketId - The localSocketId to set.

getManager

protected MultiplexingManager getManager()
Returns:

setManager

protected void setManager(MultiplexingManager manager)
Parameters:
manager - The manager to set.

setOutputShutdown

protected void setOutputShutdown(boolean outputShutdown)
Parameters:
outputShutdown - The outputShutdown to set.

setOutputStream

protected void setOutputStream(MultiplexingOutputStream outputStream)
Parameters:
outputStream - The outputStream to set.

getProtocol

protected Protocol getProtocol()
Returns:
Returns the protocol.

setProtocol

protected void setProtocol(Protocol protocol)
Parameters:
protocol - The protocol to set.

hasReceivedDisconnectMessage

protected boolean hasReceivedDisconnectMessage()
Returns:

setReceivedDisconnectMessage

protected void setReceivedDisconnectMessage(boolean receivedDisconnectMessage)
Parameters:
receivedDisconnectMessage -

setRemoteSocketId

protected void setRemoteSocketId(SocketId remoteSocketId)
Parameters:
remoteSocketId - The remoteSocketId to set.

doClose

protected void doClose()

handleRemoteOutputShutDown

protected void handleRemoteOutputShutDown()
                                   throws java.io.IOException
Throws:
java.io.IOException

handleRemoteDisconnect

protected void handleRemoteDisconnect()
                               throws java.io.IOException
Throws:
java.io.IOException

notifyOfException

protected void notifyOfException()
Indicate error condition on actual connection.



Copyright © 1998-2005 JBoss Inc . All Rights Reserved.