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 SummaryConstructors Constructor Description InternalSocket(int port)client sideInternalSocket(InputStream is, OutputStream os)server side
- 
Method SummaryModifier 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.SocketgetOption, setOption, setPerformancePreferences, setSocketImplFactory, supportedOptions
- 
Constructor Details- 
InternalSocketInternalSocket(InputStream is, OutputStream os)server side
- 
InternalSocketclient side- Parameters:
- port- > 0
- Throws:
- IOException
 
 
- 
- 
Method Details- 
getSocketConvenience method to return either a Socket or an InternalSocket- Parameters:
- port- > 0
- Throws:
- IOException
 
- 
getInputStream- Overrides:
- getInputStreamin class- Socket
 
- 
getOutputStream- Overrides:
- getOutputStreamin class- Socket
 
- 
setInputStream
- 
setOutputStream
- 
closepublic void close()
- 
isClosedpublic boolean isClosed()
- 
toString
- 
setSoTimeoutpublic void setSoTimeout(int timeout)Supported as of 0.9.34, if constructed with TimeoutPipedInputStream and TimeoutPipedOutputStream. Otherwise, does nothing.- Overrides:
- setSoTimeoutin class- Socket
- See Also:
- TimeoutPipedInputStream
 
- 
getSoTimeoutpublic int getSoTimeout()Always returns 0, even if setSoTimeout() was called.- Overrides:
- getSoTimeoutin class- Socket
 
- 
bindDeprecated.unsupported
- 
connectDeprecated.unsupported
- 
connectDeprecated.unsupported
- 
getChannelDeprecated.unsupported- Overrides:
- getChannelin class- Socket
 
- 
getInetAddressDeprecated.unsupported- Overrides:
- getInetAddressin class- Socket
 
- 
getKeepAliveDeprecated.unsupported- Overrides:
- getKeepAlivein class- Socket
 
- 
getLocalAddressDeprecated.unsupported- Overrides:
- getLocalAddressin class- Socket
 
- 
getLocalPortpublic int getLocalPort()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
- getLocalPortin class- Socket
- Returns:
- 1 if connected, -1 if not
 
- 
getLocalSocketAddressDeprecated.unsupported- Overrides:
- getLocalSocketAddressin class- Socket
 
- 
getOOBInlineDeprecated.unsupported- Overrides:
- getOOBInlinein class- Socket
 
- 
getPortpublic int getPort()Supported as of 0.9.33, prior to that threw UnsupportedOperationException
- 
getReceiveBufferSizeDeprecated.unsupported- Overrides:
- getReceiveBufferSizein class- Socket
 
- 
getRemoteSocketAddressDeprecated.unsupported- Overrides:
- getRemoteSocketAddressin class- Socket
 
- 
getReuseAddressDeprecated.unsupported- Overrides:
- getReuseAddressin class- Socket
 
- 
getSendBufferSizeDeprecated.unsupported- Overrides:
- getSendBufferSizein class- Socket
 
- 
getSoLingerpublic int getSoLinger()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
- getSoLingerin class- Socket
- Returns:
- -1 always
 
- 
getTcpNoDelayDeprecated.unsupported- Overrides:
- getTcpNoDelayin class- Socket
 
- 
getTrafficClassDeprecated.unsupported- Overrides:
- getTrafficClassin class- Socket
 
- 
isBoundDeprecated.unsupported
- 
isConnectedpublic boolean isConnected()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
- isConnectedin class- Socket
 
- 
isInputShutdownpublic boolean isInputShutdown()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
- isInputShutdownin class- Socket
 
- 
isOutputShutdownpublic boolean isOutputShutdown()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
- isOutputShutdownin class- Socket
 
- 
sendUrgentDataDeprecated.unsupported- Overrides:
- sendUrgentDatain class- Socket
 
- 
setKeepAliveDeprecated.unsupported- Overrides:
- setKeepAlivein class- Socket
 
- 
setOOBInlineDeprecated.unsupported- Overrides:
- setOOBInlinein class- Socket
 
- 
setReceiveBufferSizeDeprecated.unsupported- Overrides:
- setReceiveBufferSizein class- Socket
 
- 
setReuseAddressDeprecated.unsupported- Overrides:
- setReuseAddressin class- Socket
 
- 
setSendBufferSizeDeprecated.unsupported- Overrides:
- setSendBufferSizein class- Socket
 
- 
setSoLingerpublic void setSoLinger(boolean on, int linger)Does nothing as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
- setSoLingerin class- Socket
 
- 
setTcpNoDelayDeprecated.unsupported- Overrides:
- setTcpNoDelayin class- Socket
 
- 
setTrafficClassDeprecated.unsupported- Overrides:
- setTrafficClassin class- Socket
 
- 
shutdownInputSupported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
- shutdownInputin class- Socket
- Throws:
- IOException
 
- 
shutdownOutputFlushes (as the Socket javadocs advise) and closes. Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
- shutdownOutputin class- Socket
- Throws:
- IOException
 
 
-