org.jboss.remoting.transport.multiplex
Class VirtualSocket

java.lang.Object
  extended byjava.net.Socket
      extended byorg.jboss.remoting.transport.multiplex.VirtualSocket

public class VirtualSocket
extends java.net.Socket

Copyright (c) 2005

Author:
Ron Sigal

Field Summary
protected static org.jboss.logging.Logger log
           
 
Constructor Summary
VirtualSocket()
           
VirtualSocket(java.net.InetAddress address, int port)
           
VirtualSocket(java.net.InetAddress host, int port, boolean stream)
           
VirtualSocket(java.net.InetAddress address, int port, java.net.InetAddress localAddr, int localPort)
           
VirtualSocket(MultiplexingManager manager, SocketId remoteSocketId)
           
VirtualSocket(java.net.SocketImpl impl)
           
VirtualSocket(java.lang.String host, int port)
           
VirtualSocket(java.lang.String host, int port, boolean stream)
           
VirtualSocket(java.lang.String host, int port, java.net.InetAddress localAddr, int localPort)
           
 
Method Summary
 void bind(java.net.SocketAddress address)
          Binds the socket to a local address.
 void close()
           
 void connect(java.net.SocketAddress endpoint)
          Connects this socket to the server.
 void connect(java.net.SocketAddress socketAddress, int timeout)
          Connects this socket to the server with a specified timeout value.
protected  java.net.Socket getActualSocket()
           
 java.net.InetAddress getInetAddress()
           
 java.io.InputStream getInputStream()
           
 java.net.InetAddress getLocalAddress()
          Note.
 int getLocalPort()
           
 java.net.SocketAddress getLocalSocketAddress()
           
 SocketId getLocalSocketId()
           
 int getLocalVirtualPort()
           
protected  MultiplexingManager getManager()
           
 java.io.OutputStream getOutputStream()
           
 int getPort()
           
protected  Protocol getProtocol()
           
 java.net.SocketAddress getRemoteSocketAddress()
           
 SocketId getRemoteSocketId()
           
 int getVirtualPort()
           
 void handleRemoteDisconnect()
           
 void handleRemoteInputShutDown()
          FIXME Comment this
 void handleRemoteOutputShutDown()
          FIXME Comment this
 boolean isBound()
           
 boolean isClosed()
          Returns the closed state of the socket.
 boolean isConnected()
          Returns the connected state of the socket.
 boolean isInputShutdown()
          Returns whether the read-half of the socket connection is closed.
 boolean isOutputShutdown()
          Returns whether the write-half of the socket connection is closed.
protected  void setActualSocket(java.net.Socket actualSocket)
           
protected  void setBound(boolean bound)
           
protected  void setClosed(boolean closed)
           
protected  void setConnected(boolean connected)
           
protected  void setInputShutdown(boolean inputShutdown)
           
protected  void setInputStream(MultiplexingInputStream inputStream)
           
protected  void setLocalSocketId(SocketId localSocketId)
           
protected  void setManager(MultiplexingManager manager)
           
protected  void setOutputShutdown(boolean outputShutdown)
           
protected  void setOutputStream(MultiplexingOutputStream outputStream)
           
protected  void setProtocol(Protocol protocol)
           
protected  void setRemoteSocketId(SocketId remoteSocketId)
           
 void shutdownInput()
           
 void shutdownOutput()
           
 
Methods inherited from class java.net.Socket
getChannel, getKeepAlive, getOOBInline, getReceiveBufferSize, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, sendUrgentData, setKeepAlive, setOOBInline, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setSoLinger, setSoTimeout, setTcpNoDelay, setTrafficClass, toString
 
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
Constructor Detail

VirtualSocket

public VirtualSocket(MultiplexingManager manager,
                     SocketId remoteSocketId)
              throws java.io.IOException

VirtualSocket

public VirtualSocket()

VirtualSocket

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

VirtualSocket

public VirtualSocket(java.lang.String host,
                     int port,
                     boolean stream)
              throws java.io.IOException
Parameters:
host -
port -
stream -
Throws:
java.io.IOException

VirtualSocket

public VirtualSocket(java.net.InetAddress address,
                     int port)
              throws java.io.IOException
Parameters:
address -
port -
Throws:
java.io.IOException

VirtualSocket

public VirtualSocket(java.net.InetAddress host,
                     int port,
                     boolean stream)
              throws java.io.IOException
Parameters:
host -
port -
stream -
Throws:
java.io.IOException

VirtualSocket

public VirtualSocket(java.net.SocketImpl impl)
              throws java.net.SocketException
Parameters:
impl -
Throws:
java.net.SocketException

VirtualSocket

public VirtualSocket(java.lang.String host,
                     int port,
                     java.net.InetAddress localAddr,
                     int localPort)
              throws java.io.IOException
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
Parameters:
address -
port -
localAddr -
localPort -
Throws:
java.io.IOException
Method Detail

bind

public void bind(java.net.SocketAddress address)
          throws java.io.IOException
Binds the socket to a local address.

If the address is null, then the system will pick up an ephemeral port and a valid local address to bind the socket. TODO: security

Parameters:
address - the SocketAddress to bind to
Throws:
java.io.IOException - if the bind operation fails, or if the socket is already bound.
java.lang.IllegalArgumentException - if bindpoint is a SocketAddress subclass not supported by this socket

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

connect

public void connect(java.net.SocketAddress endpoint)
             throws java.io.IOException
Connects this socket to the server.

Parameters:
endpoint - the SocketAddress
Throws:
java.io.IOException - if an error occurs during the connection
java.lang.IllegalArgumentException - if endpoint is null or is a SocketAddress subclass not supported by this socket

connect

public void connect(java.net.SocketAddress socketAddress,
                    int timeout)
             throws java.io.IOException
Connects this socket to the server with a specified timeout value. A timeout of zero is interpreted as an infinite timeout. The connection will then block until established or an error occurs.

Parameters:
socketAddress - the SocketAddress
timeout - the timeout value to be used in milliseconds.
Throws:
java.io.IOException - if an error occurs during the connection
java.net.SocketTimeoutException - if timeout expires before connecting
java.lang.IllegalArgumentException - if endpoint is null or is a SocketAddress subclass not supported by this socket

getInetAddress

public java.net.InetAddress getInetAddress()

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Throws:
java.io.IOException

getLocalAddress

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


getLocalPort

public int getLocalPort()

getLocalSocketAddress

public java.net.SocketAddress getLocalSocketAddress()

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Throws:
java.io.IOException

getPort

public int getPort()

getRemoteSocketAddress

public java.net.SocketAddress getRemoteSocketAddress()

isBound

public boolean isBound()
Returns:
Returns the bound.

isClosed

public boolean isClosed()
Returns the closed state of the socket.


isConnected

public boolean isConnected()
Returns the connected state of the socket.


isInputShutdown

public boolean isInputShutdown()
Returns whether the read-half of the socket connection is closed.


isOutputShutdown

public boolean isOutputShutdown()
Returns whether the write-half of the socket connection is closed.


shutdownInput

public void shutdownInput()
                   throws java.io.IOException
Throws:
java.io.IOException

shutdownOutput

public void shutdownOutput()
                    throws java.io.IOException
Throws:
java.io.IOException

getVirtualPort

public int getVirtualPort()

getLocalVirtualPort

public int getLocalVirtualPort()

getLocalSocketId

public SocketId getLocalSocketId()
Returns:

getRemoteSocketId

public SocketId getRemoteSocketId()
Returns:

handleRemoteInputShutDown

public void handleRemoteInputShutDown()
                               throws java.io.IOException
FIXME Comment this

Throws:
java.io.IOException

handleRemoteOutputShutDown

public void handleRemoteOutputShutDown()
                                throws java.io.IOException
FIXME Comment this

Throws:
java.io.IOException

handleRemoteDisconnect

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

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.

getManager

protected MultiplexingManager getManager()
Returns:
Returns the manager.

setManager

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

getProtocol

protected Protocol getProtocol()
Returns:
Returns the protocol.

setProtocol

protected void setProtocol(Protocol protocol)
Parameters:
protocol - The protocol 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.

setOutputShutdown

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

setOutputStream

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

setRemoteSocketId

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


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