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 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 Detail
-
InternalSocket
InternalSocket(InputStream is, OutputStream os)
server side
-
InternalSocket
public InternalSocket(int port) throws IOExceptionclient 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:
getInputStreamin classSocket
-
getOutputStream
public OutputStream getOutputStream()
- Overrides:
getOutputStreamin 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:
setSoTimeoutin classSocket- See Also:
TimeoutPipedInputStream
-
getSoTimeout
public int getSoTimeout()
Always returns 0, even if setSoTimeout() was called.- Overrides:
getSoTimeoutin 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:
getChannelin classSocket
-
getInetAddress
@Deprecated public InetAddress getInetAddress()
Deprecated.unsupported- Overrides:
getInetAddressin classSocket
-
getKeepAlive
@Deprecated public boolean getKeepAlive()
Deprecated.unsupported- Overrides:
getKeepAlivein classSocket
-
getLocalAddress
@Deprecated public InetAddress 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 public SocketAddress getLocalSocketAddress()
Deprecated.unsupported- Overrides:
getLocalSocketAddressin classSocket
-
getOOBInline
@Deprecated public boolean getOOBInline()
Deprecated.unsupported- Overrides:
getOOBInlinein classSocket
-
getPort
public int getPort()
Supported as of 0.9.33, prior to that threw UnsupportedOperationException
-
getReceiveBufferSize
@Deprecated public int getReceiveBufferSize()
Deprecated.unsupported- Overrides:
getReceiveBufferSizein classSocket
-
getRemoteSocketAddress
@Deprecated public SocketAddress getRemoteSocketAddress()
Deprecated.unsupported- Overrides:
getRemoteSocketAddressin classSocket
-
getReuseAddress
@Deprecated public boolean getReuseAddress()
Deprecated.unsupported- Overrides:
getReuseAddressin classSocket
-
getSendBufferSize
@Deprecated public int 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 public boolean getTcpNoDelay()
Deprecated.unsupported- Overrides:
getTcpNoDelayin classSocket
-
getTrafficClass
@Deprecated public int getTrafficClass()
Deprecated.unsupported- Overrides:
getTrafficClassin classSocket
-
isBound
@Deprecated public boolean 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 public void sendUrgentData(int data)
Deprecated.unsupported- Overrides:
sendUrgentDatain classSocket
-
setKeepAlive
@Deprecated public void setKeepAlive(boolean on)
Deprecated.unsupported- Overrides:
setKeepAlivein classSocket
-
setOOBInline
@Deprecated public void setOOBInline(boolean on)
Deprecated.unsupported- Overrides:
setOOBInlinein classSocket
-
setReceiveBufferSize
@Deprecated public void setReceiveBufferSize(int size)
Deprecated.unsupported- Overrides:
setReceiveBufferSizein classSocket
-
setReuseAddress
@Deprecated public void setReuseAddress(boolean on)
Deprecated.unsupported- Overrides:
setReuseAddressin classSocket
-
setSendBufferSize
@Deprecated public void setSendBufferSize(int size)
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 public void setTcpNoDelay(boolean on)
Deprecated.unsupported- Overrides:
setTcpNoDelayin classSocket
-
setTrafficClass
@Deprecated public void setTrafficClass(int cize)
Deprecated.unsupported- Overrides:
setTrafficClassin classSocket
-
shutdownInput
public void shutdownInput() throws IOExceptionSupported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
shutdownInputin classSocket- Throws:
IOException
-
shutdownOutput
public void shutdownOutput() throws IOExceptionFlushes (as the Socket javadocs advise) and closes. Supported as of 0.9.33, prior to that threw UnsupportedOperationException- Overrides:
shutdownOutputin classSocket- Throws:
IOException
-
-