Package net.i2p.util
Class InternalSocket
java.lang.Object
java.net.Socket
net.i2p.util.InternalSocket
- All Implemented Interfaces:
Closeable,AutoCloseable
public class InternalSocket extends Socket
A simple in-JVM Socket using Piped Streams.
We use port numbers just like regular sockets.
Can only connect to InternalServerSocket.
- Since:
- 0.7.9
-
Constructor Summary
Constructors Constructor Description InternalSocket(int port)client sideInternalSocket(InputStream is, OutputStream os)server side -
Method Summary
Modifier and Type Method Description voidbind(SocketAddress endpoint)Deprecated.unsupportedvoidclose()voidconnect(SocketAddress endpoint)Deprecated.unsupportedvoidconnect(SocketAddress endpoint, int timeout)Deprecated.unsupportedSocketChannelgetChannel()Deprecated.unsupportedInetAddressgetInetAddress()Deprecated.unsupportedInputStreamgetInputStream()booleangetKeepAlive()Deprecated.unsupportedInetAddressgetLocalAddress()Deprecated.unsupportedintgetLocalPort()Supported as of 0.9.33, prior to that threw UnsupportedOperationExceptionSocketAddressgetLocalSocketAddress()Deprecated.unsupportedbooleangetOOBInline()Deprecated.unsupportedOutputStreamgetOutputStream()intgetPort()Supported as of 0.9.33, prior to that threw UnsupportedOperationExceptionintgetReceiveBufferSize()Deprecated.unsupportedSocketAddressgetRemoteSocketAddress()Deprecated.unsupportedbooleangetReuseAddress()Deprecated.unsupportedintgetSendBufferSize()Deprecated.unsupportedstatic SocketgetSocket(String host, int port)Convenience method to return either a Socket or an InternalSocketintgetSoLinger()Supported as of 0.9.33, prior to that threw UnsupportedOperationExceptionintgetSoTimeout()Always returns 0, even if setSoTimeout() was called.booleangetTcpNoDelay()Deprecated.unsupportedintgetTrafficClass()Deprecated.unsupportedbooleanisBound()Deprecated.unsupportedbooleanisClosed()booleanisConnected()Supported as of 0.9.33, prior to that threw UnsupportedOperationExceptionbooleanisInputShutdown()Supported as of 0.9.33, prior to that threw UnsupportedOperationExceptionbooleanisOutputShutdown()Supported as of 0.9.33, prior to that threw UnsupportedOperationExceptionvoidsendUrgentData(int data)Deprecated.unsupported(package private) voidsetInputStream(InputStream is)voidsetKeepAlive(boolean on)Deprecated.unsupportedvoidsetOOBInline(boolean on)Deprecated.unsupported(package private) voidsetOutputStream(OutputStream os)voidsetReceiveBufferSize(int size)Deprecated.unsupportedvoidsetReuseAddress(boolean on)Deprecated.unsupportedvoidsetSendBufferSize(int size)Deprecated.unsupportedvoidsetSoLinger(boolean on, int linger)Does nothing as of 0.9.33, prior to that threw UnsupportedOperationExceptionvoidsetSoTimeout(int timeout)Supported as of 0.9.34, if constructed with TimeoutPipedInputStream and TimeoutPipedOutputStream.voidsetTcpNoDelay(boolean on)Deprecated.unsupportedvoidsetTrafficClass(int cize)Deprecated.unsupportedvoidshutdownInput()Supported as of 0.9.33, prior to that threw UnsupportedOperationExceptionvoidshutdownOutput()Flushes (as the Socket javadocs advise) and closes.StringtoString()Methods inherited from class java.net.Socket
getOption, setOption, setPerformancePreferences, setSocketImplFactory, supportedOptions
-
Constructor Details
-
InternalSocket
InternalSocket(InputStream is, OutputStream os)server side -
InternalSocket
client side- Parameters:
port- > 0- Throws:
IOException
-
-
Method Details
-
getSocket
Convenience method to return either a Socket or an InternalSocket- Parameters:
port- > 0- Throws:
IOException
-
getInputStream
- Overrides:
getInputStreamin classSocket
-
getOutputStream
- Overrides:
getOutputStreamin classSocket
-
setInputStream
-
setOutputStream
-
close
public void close() -
isClosed
public boolean isClosed() -
toString
-
setSoTimeout
public void setSoTimeout(int timeout)Supported as of 0.9.34, if constructed with TimeoutPipedInputStream and TimeoutPipedOutputStream. Otherwise, does nothing.- Overrides:
setSoTimeoutin classSocket- See Also:
TimeoutPipedInputStream
-
getSoTimeout
public int getSoTimeout()Always returns 0, even if setSoTimeout() was called.- Overrides:
getSoTimeoutin classSocket
-
bind
Deprecated.unsupported -
connect
Deprecated.unsupported -
connect
Deprecated.unsupported -
getChannel
Deprecated.unsupported- Overrides:
getChannelin classSocket
-
getInetAddress
Deprecated.unsupported- Overrides:
getInetAddressin classSocket
-
getKeepAlive
Deprecated.unsupported- Overrides:
getKeepAlivein classSocket
-
getLocalAddress
Deprecated.unsupported- Overrides:
getLocalAddressin classSocket
-
getLocalPort
public int getLocalPort()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
getLocalPortin classSocket- Returns:
- 1 if connected, -1 if not
-
getLocalSocketAddress
Deprecated.unsupported- Overrides:
getLocalSocketAddressin classSocket
-
getOOBInline
Deprecated.unsupported- Overrides:
getOOBInlinein classSocket
-
getPort
public int getPort()Supported as of 0.9.33, prior to that threw UnsupportedOperationException -
getReceiveBufferSize
Deprecated.unsupported- Overrides:
getReceiveBufferSizein classSocket
-
getRemoteSocketAddress
Deprecated.unsupported- Overrides:
getRemoteSocketAddressin classSocket
-
getReuseAddress
Deprecated.unsupported- Overrides:
getReuseAddressin classSocket
-
getSendBufferSize
Deprecated.unsupported- Overrides:
getSendBufferSizein classSocket
-
getSoLinger
public int getSoLinger()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
getSoLingerin classSocket- Returns:
- -1 always
-
getTcpNoDelay
Deprecated.unsupported- Overrides:
getTcpNoDelayin classSocket
-
getTrafficClass
Deprecated.unsupported- Overrides:
getTrafficClassin classSocket
-
isBound
Deprecated.unsupported -
isConnected
public boolean isConnected()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
isConnectedin classSocket
-
isInputShutdown
public boolean isInputShutdown()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
isInputShutdownin classSocket
-
isOutputShutdown
public boolean isOutputShutdown()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
isOutputShutdownin classSocket
-
sendUrgentData
Deprecated.unsupported- Overrides:
sendUrgentDatain classSocket
-
setKeepAlive
Deprecated.unsupported- Overrides:
setKeepAlivein classSocket
-
setOOBInline
Deprecated.unsupported- Overrides:
setOOBInlinein classSocket
-
setReceiveBufferSize
Deprecated.unsupported- Overrides:
setReceiveBufferSizein classSocket
-
setReuseAddress
Deprecated.unsupported- Overrides:
setReuseAddressin classSocket
-
setSendBufferSize
Deprecated.unsupported- Overrides:
setSendBufferSizein classSocket
-
setSoLinger
public void setSoLinger(boolean on, int linger)Does nothing as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
setSoLingerin classSocket
-
setTcpNoDelay
Deprecated.unsupported- Overrides:
setTcpNoDelayin classSocket
-
setTrafficClass
Deprecated.unsupported- Overrides:
setTrafficClassin classSocket
-
shutdownInput
Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
shutdownInputin classSocket- Throws:
IOException
-
shutdownOutput
Flushes (as the Socket javadocs advise) and closes. Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
shutdownOutputin classSocket- Throws:
IOException
-