net.i2p.util
Class InternalServerSocket

java.lang.Object
  extended by java.net.ServerSocket
      extended by net.i2p.util.InternalServerSocket

public class InternalServerSocket
extends java.net.ServerSocket

A simple in-JVM ServerSocket using Piped Streams. We use port numbers just like regular sockets. Can only be connected by InternalSocket. Warning - this uses Piped Streams, which don't like multiple writers from threads that may vanish. If you do use multipe writers, you may get intermittent 'write end dead' or 'pipe broken' IOExceptions on the reader side. See http://techtavern.wordpress.com/2008/07/16/whats-this-ioexception-write-end-dead/

Since:
0.7.9

Constructor Summary
InternalServerSocket(int port)
           
 
Method Summary
 java.net.Socket accept()
           
 void bind(java.net.SocketAddress endpoint)
          Deprecated. unsupported
 void bind(java.net.SocketAddress endpoint, int backlog)
          Deprecated. unsupported
 void close()
           
 java.nio.channels.ServerSocketChannel getChannel()
          Deprecated. unsupported
 java.net.InetAddress getInetAddress()
          Deprecated. unsupported
 int getLocalPort()
           
 java.net.SocketAddress getLocalSocketAddress()
          Deprecated. unsupported
 int getReceiveBufferSize()
          Deprecated. unsupported
 boolean getReuseAddress()
          Deprecated. unsupported
 int getSoTimeout()
           
(package private) static void internalConnect(int port, InternalSocket clientSock)
          This is how the client connects.
 boolean isBound()
          Deprecated. unsupported
 boolean isClosed()
          Deprecated. unsupported
 void setReceiveBufferSize(int size)
          Deprecated. unsupported
 void setReuseAddress(boolean on)
          Deprecated. unsupported
 void setSoTimeout(int timeout)
          warning - unsupported
 java.lang.String toString()
           
 
Methods inherited from class java.net.ServerSocket
implAccept, setPerformancePreferences, setSocketFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InternalServerSocket

public InternalServerSocket(int port)
                     throws java.io.IOException
Throws:
java.io.IOException
Method Detail

close

public void close()
Overrides:
close in class java.net.ServerSocket

accept

public java.net.Socket accept()
                       throws java.io.IOException
Overrides:
accept in class java.net.ServerSocket
Throws:
java.io.IOException

toString

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

internalConnect

static void internalConnect(int port,
                            InternalSocket clientSock)
                     throws java.io.IOException
This is how the client connects. Todo: Java 1.5 PipedInputStream buffers are only 1024 bytes; our I2CP messages are typically 1730 bytes, thus causing thread blockage before the whole message is transferred. We can specify buffer size in 1.6 but not in 1.5. Does wrapping the PipedOutputStreams in BufferedOutputStreams gain capacity? No?

Throws:
java.io.IOException

getLocalPort

public int getLocalPort()
Overrides:
getLocalPort in class java.net.ServerSocket

setSoTimeout

public void setSoTimeout(int timeout)
warning - unsupported

Overrides:
setSoTimeout in class java.net.ServerSocket

getSoTimeout

public int getSoTimeout()
Overrides:
getSoTimeout in class java.net.ServerSocket

bind

public void bind(java.net.SocketAddress endpoint)
Deprecated. unsupported

Overrides:
bind in class java.net.ServerSocket

bind

public void bind(java.net.SocketAddress endpoint,
                 int backlog)
Deprecated. unsupported

Overrides:
bind in class java.net.ServerSocket

getChannel

public java.nio.channels.ServerSocketChannel getChannel()
Deprecated. unsupported

Overrides:
getChannel in class java.net.ServerSocket

getInetAddress

public java.net.InetAddress getInetAddress()
Deprecated. unsupported

Overrides:
getInetAddress in class java.net.ServerSocket

getLocalSocketAddress

public java.net.SocketAddress getLocalSocketAddress()
Deprecated. unsupported

Overrides:
getLocalSocketAddress in class java.net.ServerSocket

getReceiveBufferSize

public int getReceiveBufferSize()
Deprecated. unsupported

Overrides:
getReceiveBufferSize in class java.net.ServerSocket

getReuseAddress

public boolean getReuseAddress()
Deprecated. unsupported

Overrides:
getReuseAddress in class java.net.ServerSocket

isBound

public boolean isBound()
Deprecated. unsupported

Overrides:
isBound in class java.net.ServerSocket

isClosed

public boolean isClosed()
Deprecated. unsupported

Overrides:
isClosed in class java.net.ServerSocket

setReceiveBufferSize

public void setReceiveBufferSize(int size)
Deprecated. unsupported

Overrides:
setReceiveBufferSize in class java.net.ServerSocket

setReuseAddress

public void setReuseAddress(boolean on)
Deprecated. unsupported

Overrides:
setReuseAddress in class java.net.ServerSocket