edu.emory.mathcs.util.net.inproc
Class InProcSocket

java.lang.Object
  extended byjava.net.Socket
      extended byedu.emory.mathcs.util.net.inproc.InProcSocket

public class InProcSocket
extends java.net.Socket

Abstraction of a socket accessible only within a process. While this class fully adheres to the socket API, it is a socket that can only connect to an appropriate "server socket" within the same process.

Version:
1.0
Author:
Dawid Kurzyniec
See Also:
InProcServerSocket

Constructor Summary
InProcSocket()
          Creates new, unconnected in-process socket.
InProcSocket(int port)
          Creates new in-process socket and connects it to a server socket listening on a specified port.
 
Method Summary
 void bind(java.net.SocketAddress bindpoint)
          Not supported.
 void close()
           
 void connect(java.net.SocketAddress endpoint, int timeout)
          Connects the socket to the in-proc server socket.
 java.net.InetAddress getInetAddress()
          Returns a dummy "local" IP address of the form 127.0.0.129.
 java.io.InputStream getInputStream()
           
 boolean getKeepAlive()
          Returns true.
 java.net.InetAddress getLocalAddress()
          Returns a dummy "local" IP address of the form 127.0.0.129.
 int getLocalPort()
          Not meaningful.
 java.net.SocketAddress getLocalSocketAddress()
          Returns an InProcSocketAddress holding local port number, as obtained via getLocalPort().
 boolean getOOBInline()
          Returns false.
 java.io.OutputStream getOutputStream()
           
 int getPort()
           
 int getReceiveBufferSize()
           
 java.net.SocketAddress getRemoteSocketAddress()
          Returns server endpoint information as InProcSocketAddress.
 boolean getReuseAddress()
          Returns true.
 int getSendBufferSize()
           
 int getSoLinger()
          Returns -1.
 int getSoTimeout()
           
 boolean getTcpNoDelay()
          Returns true.
 int getTrafficClass()
          Returns 0.
 boolean isBound()
           
 boolean isClosed()
           
 boolean isConnected()
           
 boolean isInputShutdown()
           
 boolean isOutputShutdown()
           
 void sendUrgentData(int data)
          Unsupported.
 void setKeepAlive(boolean on)
          Does nothing.
 void setOOBInline(boolean on)
          Does nothing.
 void setReceiveBufferSize(int size)
           
 void setReuseAddress(boolean on)
          Does nothing.
 void setSendBufferSize(int size)
           
 void setSoLinger(boolean on, int linger)
          Does nothing.
 void setSoTimeout(int timeout)
           
 void setTcpNoDelay(boolean on)
          Does nothing.
 void setTrafficClass(int tc)
          Does nothing.
 void shutdownInput()
           
 void shutdownOutput()
           
 java.lang.String toString()
           
 
Methods inherited from class java.net.Socket
connect, getChannel, setSocketImplFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InProcSocket

public InProcSocket(int port)
             throws java.io.IOException
Creates new in-process socket and connects it to a server socket listening on a specified port.

Parameters:
port - the port to connect to
Throws:
java.io.IOException - if I/O error occurs

InProcSocket

public InProcSocket()
             throws java.net.SocketException
Creates new, unconnected in-process socket.

Throws:
java.net.SocketException - thrown by a superclass constructor
Method Detail

connect

public void connect(java.net.SocketAddress endpoint,
                    int timeout)
             throws java.io.IOException
Connects the socket to the in-proc server socket. The endpoint must be an instance of InProcSocketAddress, that is, it must provide an in-proc port number to connect to.

Parameters:
endpoint - the in-proc endpoint to connect to
timeout - the timeout to wait for a connection to be established
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 not a InProcSocketAddress instance

bind

public void bind(java.net.SocketAddress bindpoint)
          throws java.io.IOException
Not supported. In-proc client sockets do not have meaningful local addresses (port numbers).

Parameters:
bindpoint -
Throws:
java.io.IOException

getInetAddress

public java.net.InetAddress getInetAddress()
Returns a dummy "local" IP address of the form 127.0.0.129. It helps security managers to recognize this as a "localhost" socket

Returns:
IP address of 127.0.0.129.

getLocalAddress

public java.net.InetAddress getLocalAddress()
Returns a dummy "local" IP address of the form 127.0.0.129. It helps security managers to recognize this as a "localhost" socket

Returns:
IP address of 127.0.0.129.

getPort

public int getPort()

getLocalPort

public int getLocalPort()
Not meaningful. In-proc client sockets do not have meaningful local addresses (port numbers).

Returns:
meaningless number

getRemoteSocketAddress

public java.net.SocketAddress getRemoteSocketAddress()
Returns server endpoint information as InProcSocketAddress.

Returns:
server endpoint information

getLocalSocketAddress

public java.net.SocketAddress getLocalSocketAddress()
Returns an InProcSocketAddress holding local port number, as obtained via getLocalPort().

Returns:
client endpoint information

getInputStream

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

getOutputStream

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

setTcpNoDelay

public void setTcpNoDelay(boolean on)
                   throws java.net.SocketException
Does nothing.

Throws:
java.net.SocketException

getTcpNoDelay

public boolean getTcpNoDelay()
                      throws java.net.SocketException
Returns true.

Throws:
java.net.SocketException

setSoLinger

public void setSoLinger(boolean on,
                        int linger)
                 throws java.net.SocketException
Does nothing.

Throws:
java.net.SocketException

getSoLinger

public int getSoLinger()
                throws java.net.SocketException
Returns -1.

Throws:
java.net.SocketException

sendUrgentData

public void sendUrgentData(int data)
                    throws java.io.IOException
Unsupported.

Throws:
java.io.IOException

setOOBInline

public void setOOBInline(boolean on)
                  throws java.net.SocketException
Does nothing.

Throws:
java.net.SocketException

getOOBInline

public boolean getOOBInline()
                     throws java.net.SocketException
Returns false.

Throws:
java.net.SocketException

setSoTimeout

public void setSoTimeout(int timeout)
                  throws java.net.SocketException
Throws:
java.net.SocketException

getSoTimeout

public int getSoTimeout()
                 throws java.net.SocketException
Throws:
java.net.SocketException

setSendBufferSize

public void setSendBufferSize(int size)
                       throws java.net.SocketException
Throws:
java.net.SocketException

getSendBufferSize

public int getSendBufferSize()
                      throws java.net.SocketException
Throws:
java.net.SocketException

setReceiveBufferSize

public void setReceiveBufferSize(int size)
                          throws java.net.SocketException
Throws:
java.net.SocketException

getReceiveBufferSize

public int getReceiveBufferSize()
                         throws java.net.SocketException
Throws:
java.net.SocketException

setKeepAlive

public void setKeepAlive(boolean on)
                  throws java.net.SocketException
Does nothing.

Throws:
java.net.SocketException

getKeepAlive

public boolean getKeepAlive()
                     throws java.net.SocketException
Returns true.

Throws:
java.net.SocketException

setTrafficClass

public void setTrafficClass(int tc)
                     throws java.net.SocketException
Does nothing.

Throws:
java.net.SocketException

getTrafficClass

public int getTrafficClass()
                    throws java.net.SocketException
Returns 0.

Throws:
java.net.SocketException

setReuseAddress

public void setReuseAddress(boolean on)
                     throws java.net.SocketException
Does nothing.

Throws:
java.net.SocketException

getReuseAddress

public boolean getReuseAddress()
                        throws java.net.SocketException
Returns true.

Throws:
java.net.SocketException

close

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

shutdownInput

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

shutdownOutput

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

toString

public java.lang.String toString()

isConnected

public boolean isConnected()

isBound

public boolean isBound()

isClosed

public boolean isClosed()

isInputShutdown

public boolean isInputShutdown()

isOutputShutdown

public boolean isOutputShutdown()