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
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 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 Detail
-
InternalSocket
InternalSocket(InputStream is, OutputStream os)
server side
-
InternalSocket
public InternalSocket(int port) throws IOException
client side- Parameters:
port
- > 0- Throws:
IOException
-
-
Method Detail
-
getSocket
public static Socket getSocket(String host, int port) throws IOException
Convenience method to return either a Socket or an InternalSocket- Parameters:
port
- > 0- Throws:
IOException
-
getInputStream
public InputStream getInputStream()
- Overrides:
getInputStream
in classSocket
-
getOutputStream
public OutputStream getOutputStream()
- Overrides:
getOutputStream
in classSocket
-
setInputStream
void setInputStream(InputStream is)
-
setOutputStream
void setOutputStream(OutputStream os)
-
close
public void close()
-
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 public void bind(SocketAddress endpoint)
Deprecated.unsupported
-
connect
@Deprecated public void connect(SocketAddress endpoint)
Deprecated.unsupported
-
connect
@Deprecated public void connect(SocketAddress endpoint, int timeout)
Deprecated.unsupported
-
getChannel
@Deprecated public SocketChannel getChannel()
Deprecated.unsupported- Overrides:
getChannel
in classSocket
-
getInetAddress
@Deprecated public InetAddress getInetAddress()
Deprecated.unsupported- Overrides:
getInetAddress
in classSocket
-
getKeepAlive
@Deprecated public boolean getKeepAlive()
Deprecated.unsupported- Overrides:
getKeepAlive
in classSocket
-
getLocalAddress
@Deprecated public InetAddress 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 public SocketAddress getLocalSocketAddress()
Deprecated.unsupported- Overrides:
getLocalSocketAddress
in classSocket
-
getOOBInline
@Deprecated public boolean getOOBInline()
Deprecated.unsupported- Overrides:
getOOBInline
in classSocket
-
getPort
public int getPort()
Supported as of 0.9.33, prior to that threw UnsupportedOperationException
-
getReceiveBufferSize
@Deprecated public int getReceiveBufferSize()
Deprecated.unsupported- Overrides:
getReceiveBufferSize
in classSocket
-
getRemoteSocketAddress
@Deprecated public SocketAddress getRemoteSocketAddress()
Deprecated.unsupported- Overrides:
getRemoteSocketAddress
in classSocket
-
getReuseAddress
@Deprecated public boolean getReuseAddress()
Deprecated.unsupported- Overrides:
getReuseAddress
in classSocket
-
getSendBufferSize
@Deprecated public int 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 public boolean getTcpNoDelay()
Deprecated.unsupported- Overrides:
getTcpNoDelay
in classSocket
-
getTrafficClass
@Deprecated public int getTrafficClass()
Deprecated.unsupported- Overrides:
getTrafficClass
in classSocket
-
isBound
@Deprecated public boolean 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 public void sendUrgentData(int data)
Deprecated.unsupported- Overrides:
sendUrgentData
in classSocket
-
setKeepAlive
@Deprecated public void setKeepAlive(boolean on)
Deprecated.unsupported- Overrides:
setKeepAlive
in classSocket
-
setOOBInline
@Deprecated public void setOOBInline(boolean on)
Deprecated.unsupported- Overrides:
setOOBInline
in classSocket
-
setReceiveBufferSize
@Deprecated public void setReceiveBufferSize(int size)
Deprecated.unsupported- Overrides:
setReceiveBufferSize
in classSocket
-
setReuseAddress
@Deprecated public void setReuseAddress(boolean on)
Deprecated.unsupported- Overrides:
setReuseAddress
in classSocket
-
setSendBufferSize
@Deprecated public void setSendBufferSize(int size)
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 public void setTcpNoDelay(boolean on)
Deprecated.unsupported- Overrides:
setTcpNoDelay
in classSocket
-
setTrafficClass
@Deprecated public void setTrafficClass(int cize)
Deprecated.unsupported- Overrides:
setTrafficClass
in classSocket
-
shutdownInput
public void shutdownInput() throws IOException
Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
shutdownInput
in classSocket
- Throws:
IOException
-
shutdownOutput
public void shutdownOutput() throws IOException
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
-
-