Top Description Fields Constructors Methods
java.net

pack-priv Class SocksSocketImpl

extends DelegatingSocketImpl
implements SocksConsts
Class Inheritance
All Implemented Interfaces
java.net.SocksConsts
Imports
java.io.IOException, .InputStream, .OutputStream, .BufferedOutputStream, java.nio.charset.StandardCharsets, java.util.Iterator, jdk.internal.util.StaticProperty, sun.net.SocksProxy, sun.net.spi.DefaultProxySelector, sun.net.www.ParseUtil

SOCKS (V4 & V5) TCP socket implementation (RFC 1928).

Field Summary

Modifier and TypeField and Description
private InputStream
private OutputStream
private Socket
private InetSocketAddress
private String
private int
private boolean
Inherited from java.net.DelegatingSocketImpl:
delegate

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
SocksSocketImpl(Proxy proxy, SocketImpl delegate)

Method Summary

Modifier and TypeMethod and Description
protected void
accept(SocketImpl
the accepted connection.
s
)

Overrides java.net.DelegatingSocketImpl.accept.

Accepts a connection.

private boolean
authenticate(byte method, InputStream in, BufferedOutputStream out, long deadlineMillis)

protected void
close()

Overrides java.net.DelegatingSocketImpl.close.

Closes this socket.

protected void
connect(String
the name of the remote host.
host
,
int
the port number.
port
)

Overrides java.net.DelegatingSocketImpl.connect.

Connects this socket to the specified port on the named host.

protected void
connect(InetAddress
the IP address of the remote host.
address
,
int
the port number.
port
)

Overrides java.net.DelegatingSocketImpl.connect.

Connects this socket to the specified port number on the specified host.

protected void
connect(SocketAddress
the SocketAddress to connect to.
endpoint
,
int
the timeout value in milliseconds
timeout
)

Overrides java.net.DelegatingSocketImpl.connect.

Connects the Socks Socket to the specified endpoint.

private void
connectV4(InputStream in, OutputStream out, InetSocketAddress endpoint, long deadlineMillis)

private synchronized void
doConnect(final String host, final int port, final int timeout)

protected InetAddress

Returns:

the value of this socket's address field.
getInetAddress
()

Overrides java.net.DelegatingSocketImpl.getInetAddress.

Returns the value of this socket's address field.

protected int

Returns:

the value of this socket's port field.
getPort
()

Overrides java.net.DelegatingSocketImpl.getPort.

Returns the value of this socket's port field.

private String
protected void
listen(int
the maximum length of the queue.
backlog
)

Overrides java.net.DelegatingSocketImpl.listen.

Sets the maximum queue length for incoming connection indications (a request to connect) to the count argument.

private int
readSocksReply(InputStream in, byte[] data, long deadlineMillis)

private static int
remainingMillis(long deadlineMillis)

pack-priv void
private static boolean
useV4(Proxy proxy)

Inherited from java.net.DelegatingSocketImpl:
availablebindcreatedelegategetFileDescriptorgetInputStreamgetLocalPortgetOptiongetOptiongetOutputStreamsendUrgentDatasetOptionsetOptionshutdownInputshutdownOutputsupportedOptionssupportsUrgentData

Field Detail

cmdInback to summary
private InputStream cmdIn
cmdOutback to summary
private OutputStream cmdOut
cmdsockback to summary
private Socket cmdsock
external_addressback to summary
private InetSocketAddress external_address
serverback to summary
private String server
serverPortback to summary
private int serverPort
useV4back to summary
private boolean useV4

Constructor Detail

SocksSocketImplback to summary
pack-priv SocksSocketImpl(SocketImpl delegate)
SocksSocketImplback to summary
pack-priv SocksSocketImpl(Proxy proxy, SocketImpl delegate)

Method Detail

acceptback to summary
protected void accept(SocketImpl s)

Overrides java.net.DelegatingSocketImpl.accept.

Doc from java.net.SocketImpl.accept.

Accepts a connection.

Parameters
s:SocketImpl

the accepted connection.

Annotations
@Override
authenticateback to summary
private boolean authenticate(byte method, InputStream in, BufferedOutputStream out, long deadlineMillis) throws IOException
closeback to summary
protected void close() throws IOException

Overrides java.net.DelegatingSocketImpl.close.

Doc from java.net.SocketImpl.close.

Closes this socket.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when closing this socket.
connectback to summary
protected void connect(String host, int port) throws IOException

Overrides java.net.DelegatingSocketImpl.connect.

Doc from java.net.SocketImpl.connect.

Connects this socket to the specified port on the named host.

Parameters
host:String

the name of the remote host.

port:int

the port number.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when connecting to the remote host.
connectback to summary
protected void connect(InetAddress address, int port) throws IOException

Overrides java.net.DelegatingSocketImpl.connect.

Doc from java.net.SocketImpl.connect.

Connects this socket to the specified port number on the specified host.

Parameters
address:InetAddress

the IP address of the remote host.

port:int

the port number.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when attempting a connection.
connectback to summary
protected void connect(SocketAddress endpoint, int timeout) throws IOException

Overrides java.net.DelegatingSocketImpl.connect.

Connects the Socks Socket to the specified endpoint. It will first connect to the SOCKS proxy and negotiate the access. If the proxy grants the connections, then the connect is successful and all further traffic will go to the "real" endpoint.

Parameters
endpoint:SocketAddress

the SocketAddress to connect to.

timeout:int

the timeout value in milliseconds

Annotations
@Override
Exceptions
IOException:
if the connection can't be established.
IllegalArgumentException:
if endpoint is null or a SocketAddress subclass not supported by this socket
connectV4back to summary
private void connectV4(InputStream in, OutputStream out, InetSocketAddress endpoint, long deadlineMillis) throws IOException
doConnectback to summary
private synchronized void doConnect(final String host, final int port, final int timeout) throws IOException
getInetAddressback to summary
protected InetAddress getInetAddress()

Overrides java.net.DelegatingSocketImpl.getInetAddress.

Returns the value of this socket's address field.

Returns:InetAddress

the value of this socket's address field.

Annotations
@Override
See Also
java.net.SocketImpl#address
getPortback to summary
protected int getPort()

Overrides java.net.DelegatingSocketImpl.getPort.

Returns the value of this socket's port field.

Returns:int

the value of this socket's port field.

Annotations
@Override
See Also
java.net.SocketImpl#port
getUserNameback to summary
private String getUserName()
listenback to summary
protected void listen(int backlog)

Overrides java.net.DelegatingSocketImpl.listen.

Doc from java.net.SocketImpl.listen.

Sets the maximum queue length for incoming connection indications (a request to connect) to the count argument. If a connection indication arrives when the queue is full, the connection is refused.

Parameters
backlog:int

the maximum length of the queue.

Annotations
@Override
readSocksReplyback to summary
private int readSocksReply(InputStream in, byte[] data, long deadlineMillis) throws IOException
remainingMillisback to summary
private static int remainingMillis(long deadlineMillis) throws IOException
resetback to summary
pack-priv void reset()

Overrides java.net.SocketImpl.reset.

Annotations
@Override
useV4back to summary
private static boolean useV4(Proxy proxy)