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 void
bind(SocketAddress endpoint)
Deprecated.unsupportedvoid
close()
void
connect(SocketAddress endpoint)
Deprecated.unsupportedvoid
connect(SocketAddress endpoint, int timeout)
Deprecated.unsupportedSocketChannel
getChannel()
Deprecated.unsupportedInetAddress
getInetAddress()
Deprecated.unsupportedInputStream
getInputStream()
boolean
getKeepAlive()
Deprecated.unsupportedInetAddress
getLocalAddress()
Deprecated.unsupportedint
getLocalPort()
Supported as of 0.9.33, prior to that threw UnsupportedOperationExceptionSocketAddress
getLocalSocketAddress()
Deprecated.unsupportedboolean
getOOBInline()
Deprecated.unsupportedOutputStream
getOutputStream()
int
getPort()
Supported as of 0.9.33, prior to that threw UnsupportedOperationExceptionint
getReceiveBufferSize()
Deprecated.unsupportedSocketAddress
getRemoteSocketAddress()
Deprecated.unsupportedboolean
getReuseAddress()
Deprecated.unsupportedint
getSendBufferSize()
Deprecated.unsupportedstatic Socket
getSocket(String host, int port)
Convenience method to return either a Socket or an InternalSocketint
getSoLinger()
Supported as of 0.9.33, prior to that threw UnsupportedOperationExceptionint
getSoTimeout()
Always returns 0, even if setSoTimeout() was called.boolean
getTcpNoDelay()
Deprecated.unsupportedint
getTrafficClass()
Deprecated.unsupportedboolean
isBound()
Deprecated.unsupportedboolean
isClosed()
boolean
isConnected()
Supported as of 0.9.33, prior to that threw UnsupportedOperationExceptionboolean
isInputShutdown()
Supported as of 0.9.33, prior to that threw UnsupportedOperationExceptionboolean
isOutputShutdown()
Supported as of 0.9.33, prior to that threw UnsupportedOperationExceptionvoid
sendUrgentData(int data)
Deprecated.unsupported(package private) void
setInputStream(InputStream is)
void
setKeepAlive(boolean on)
Deprecated.unsupportedvoid
setOOBInline(boolean on)
Deprecated.unsupported(package private) void
setOutputStream(OutputStream os)
void
setReceiveBufferSize(int size)
Deprecated.unsupportedvoid
setReuseAddress(boolean on)
Deprecated.unsupportedvoid
setSendBufferSize(int size)
Deprecated.unsupportedvoid
setSoLinger(boolean on, int linger)
Does nothing as of 0.9.33, prior to that threw UnsupportedOperationExceptionvoid
setSoTimeout(int timeout)
Supported as of 0.9.34, if constructed with TimeoutPipedInputStream and TimeoutPipedOutputStream.void
setTcpNoDelay(boolean on)
Deprecated.unsupportedvoid
setTrafficClass(int cize)
Deprecated.unsupportedvoid
shutdownInput()
Supported as of 0.9.33, prior to that threw UnsupportedOperationExceptionvoid
shutdownOutput()
Flushes (as the Socket javadocs advise) and closes.String
toString()
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:
getInputStream
in classSocket
-
getOutputStream
- Overrides:
getOutputStream
in 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:
setSoTimeout
in classSocket
- See Also:
TimeoutPipedInputStream
-
getSoTimeout
public int getSoTimeout()Always returns 0, even if setSoTimeout() was called.- Overrides:
getSoTimeout
in classSocket
-
bind
Deprecated.unsupported -
connect
Deprecated.unsupported -
connect
Deprecated.unsupported -
getChannel
Deprecated.unsupported- Overrides:
getChannel
in classSocket
-
getInetAddress
Deprecated.unsupported- Overrides:
getInetAddress
in classSocket
-
getKeepAlive
Deprecated.unsupported- Overrides:
getKeepAlive
in classSocket
-
getLocalAddress
Deprecated.unsupported- Overrides:
getLocalAddress
in classSocket
-
getLocalPort
public int getLocalPort()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
getLocalPort
in classSocket
- Returns:
- 1 if connected, -1 if not
-
getLocalSocketAddress
Deprecated.unsupported- Overrides:
getLocalSocketAddress
in classSocket
-
getOOBInline
Deprecated.unsupported- Overrides:
getOOBInline
in classSocket
-
getPort
public int getPort()Supported as of 0.9.33, prior to that threw UnsupportedOperationException -
getReceiveBufferSize
Deprecated.unsupported- Overrides:
getReceiveBufferSize
in classSocket
-
getRemoteSocketAddress
Deprecated.unsupported- Overrides:
getRemoteSocketAddress
in classSocket
-
getReuseAddress
Deprecated.unsupported- Overrides:
getReuseAddress
in classSocket
-
getSendBufferSize
Deprecated.unsupported- Overrides:
getSendBufferSize
in classSocket
-
getSoLinger
public int getSoLinger()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
getSoLinger
in classSocket
- Returns:
- -1 always
-
getTcpNoDelay
Deprecated.unsupported- Overrides:
getTcpNoDelay
in classSocket
-
getTrafficClass
Deprecated.unsupported- Overrides:
getTrafficClass
in classSocket
-
isBound
Deprecated.unsupported -
isConnected
public boolean isConnected()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
isConnected
in classSocket
-
isInputShutdown
public boolean isInputShutdown()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
isInputShutdown
in classSocket
-
isOutputShutdown
public boolean isOutputShutdown()Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
isOutputShutdown
in classSocket
-
sendUrgentData
Deprecated.unsupported- Overrides:
sendUrgentData
in classSocket
-
setKeepAlive
Deprecated.unsupported- Overrides:
setKeepAlive
in classSocket
-
setOOBInline
Deprecated.unsupported- Overrides:
setOOBInline
in classSocket
-
setReceiveBufferSize
Deprecated.unsupported- Overrides:
setReceiveBufferSize
in classSocket
-
setReuseAddress
Deprecated.unsupported- Overrides:
setReuseAddress
in classSocket
-
setSendBufferSize
Deprecated.unsupported- Overrides:
setSendBufferSize
in classSocket
-
setSoLinger
public void setSoLinger(boolean on, int linger)Does nothing as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
setSoLinger
in classSocket
-
setTcpNoDelay
Deprecated.unsupported- Overrides:
setTcpNoDelay
in classSocket
-
setTrafficClass
Deprecated.unsupported- Overrides:
setTrafficClass
in classSocket
-
shutdownInput
Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
shutdownInput
in classSocket
- Throws:
IOException
-
shutdownOutput
Flushes (as the Socket javadocs advise) and closes. Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
shutdownOutput
in classSocket
- Throws:
IOException
-