Package net.i2p.util
Class InternalServerSocket
java.lang.Object
java.net.ServerSocket
net.i2p.util.InternalServerSocket
- All Implemented Interfaces:
Closeable,AutoCloseable
public class InternalServerSocket extends 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
Constructors Constructor Description InternalServerSocket(int port) -
Method Summary
Modifier and Type Method Description Socketaccept()voidbind(SocketAddress endpoint)Deprecated.unsupportedvoidbind(SocketAddress endpoint, int backlog)Deprecated.unsupportedvoidclose()ServerSocketChannelgetChannel()Returns null as of 0.9.33, prior to that threw IllegalArgumentExceptionInetAddressgetInetAddress()Deprecated.unsupportedintgetLocalPort()SocketAddressgetLocalSocketAddress()Deprecated.unsupportedintgetReceiveBufferSize()Deprecated.unsupportedbooleangetReuseAddress()Deprecated.unsupportedintgetSoTimeout()(package private) static voidinternalConnect(int port, InternalSocket clientSock)This is how the client connects.booleanisBound()Returns true as of 0.9.33, prior to that threw IllegalArgumentExceptionbooleanisClosed()Supported as of 0.9.33, prior to that threw IllegalArgumentExceptionstatic voidrenderStatusHTML(Writer out)For debugging onlyvoidsetReceiveBufferSize(int size)Deprecated.unsupportedvoidsetReuseAddress(boolean on)Deprecated.unsupportedvoidsetSoTimeout(int timeout)warning - unsupportedStringtoString()Methods inherited from class java.net.ServerSocket
getOption, implAccept, setOption, setPerformancePreferences, setSocketFactory, supportedOptions
-
Constructor Details
-
InternalServerSocket
- Parameters:
port- > 0- Throws:
IOException
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classServerSocket
-
accept
- Overrides:
acceptin classServerSocket- Throws:
IOException
-
toString
- Overrides:
toStringin classServerSocket
-
internalConnect
This is how the client connects.- Parameters:
port- > 0- Throws:
IOException
-
getLocalPort
public int getLocalPort()- Overrides:
getLocalPortin classServerSocket
-
setSoTimeout
public void setSoTimeout(int timeout)warning - unsupported- Overrides:
setSoTimeoutin classServerSocket
-
getSoTimeout
public int getSoTimeout()- Overrides:
getSoTimeoutin classServerSocket
-
bind
Deprecated.unsupported- Overrides:
bindin classServerSocket
-
bind
Deprecated.unsupported- Overrides:
bindin classServerSocket
-
getChannel
Returns null as of 0.9.33, prior to that threw IllegalArgumentException- Overrides:
getChannelin classServerSocket
-
getInetAddress
Deprecated.unsupported- Overrides:
getInetAddressin classServerSocket
-
getLocalSocketAddress
Deprecated.unsupported- Overrides:
getLocalSocketAddressin classServerSocket
-
getReceiveBufferSize
Deprecated.unsupported- Overrides:
getReceiveBufferSizein classServerSocket
-
getReuseAddress
Deprecated.unsupported- Overrides:
getReuseAddressin classServerSocket
-
isBound
public boolean isBound()Returns true as of 0.9.33, prior to that threw IllegalArgumentException- Overrides:
isBoundin classServerSocket
-
isClosed
public boolean isClosed()Supported as of 0.9.33, prior to that threw IllegalArgumentException- Overrides:
isClosedin classServerSocket
-
setReceiveBufferSize
Deprecated.unsupported- Overrides:
setReceiveBufferSizein classServerSocket
-
setReuseAddress
Deprecated.unsupported- Overrides:
setReuseAddressin classServerSocket
-
renderStatusHTML
For debugging only- Throws:
IOException- Since:
- 0.9.33
-