public class SocksSocket extends Socket
SocksSocket is proxy class that help developers use SocksProxy as
same as a java.net.Socket.
SocksProxy proxy = new Socks5(new InetSocketAddress("127.0.0.1", 1080));
// Setting proxy...
Socket socket = new SocksSocket(proxy, new InetSocketAddress("whois.internic.net", 43));
InputStream inputStream = socket.getInputStream();
OutputStream outStream = socket.getOutputStream();
// Just use the socket as normal java.net.Socket now.
| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
SocksSocket(SocksProxy proxy)
Creates an unconnected socket.
|
SocksSocket(SocksProxy proxy,
InetAddress address,
int port)
|
SocksSocket(SocksProxy proxy,
Socket proxySocket)
Creates a SocksSocket instance with a
SocksProxy and a |
SocksSocket(SocksProxy proxy,
SocketAddress socketAddress) |
SocksSocket(SocksProxy proxy,
String remoteServerHost,
int remoteServerPort)
Create a socket and connect SOCKS Server.
|
setSocketImplFactory, toStringpublic SocksSocket(SocksProxy proxy, String remoteServerHost, int remoteServerPort) throws SocksException, IOException
proxy - Socks proxy.remoteServerHost - Remote sever host.remoteServerPort - Remote server port.SocksException - If any errors about SOCKS protocol occurred.IOException - If any IO errors occurred.public SocksSocket(SocksProxy proxy, InetAddress address, int port) throws SocksException, IOException
proxy - Socks proxy.address - Remote server's IP address.port - Remote server's port.SocksException - If any error about SOCKS protocol occurs.IOException - If I/O error occurs.public SocksSocket(SocksProxy proxy, SocketAddress socketAddress) throws SocksException, IOException
SocksExceptionIOExceptionpublic SocksSocket(SocksProxy proxy) throws IOException
proxy - SOCKS proxy.IOException - If an I/O error occurred.public SocksSocket(SocksProxy proxy, Socket proxySocket)
SocksProxy and aproxy - SOCKS proxy.proxySocket - a unconnected socket. it will connect SOCKS server later.public void connect(String host, int port) throws SocksException, IOException
host - Remote server's host.port - Remote server's port.SocksException - If any error about SOCKS protocol occurs.IOException - If I/O error occurs.public void connect(SocketAddress endpoint) throws SocksException, IOException
connect in class SocketSocksExceptionIOExceptionpublic void connect(SocketAddress endpoint, int timeout) throws SocksException, IOException
connect in class SocketSocksExceptionIOExceptionpublic InputStream getInputStream() throws IOException
getInputStream in class SocketIOExceptionpublic OutputStream getOutputStream() throws IOException
getOutputStream in class SocketIOExceptionpublic void bind(SocketAddress bindpoint) throws IOException
bind in class SocketIOExceptionpublic InetAddress getInetAddress()
getInetAddress in class Socketpublic InetAddress getLocalAddress()
getLocalAddress in class Socketpublic int getLocalPort()
getLocalPort in class Socketpublic SocketAddress getRemoteSocketAddress()
getRemoteSocketAddress in class Socketpublic SocketAddress getLocalSocketAddress()
getLocalSocketAddress in class Socketpublic SocketChannel getChannel()
getChannel in class Socketpublic void setTcpNoDelay(boolean on)
throws SocketException
setTcpNoDelay in class SocketSocketExceptionpublic boolean getTcpNoDelay()
throws SocketException
getTcpNoDelay in class SocketSocketExceptionpublic void setSoLinger(boolean on,
int linger)
throws SocketException
setSoLinger in class SocketSocketExceptionpublic int getSoLinger()
throws SocketException
getSoLinger in class SocketSocketExceptionpublic void sendUrgentData(int data)
throws IOException
sendUrgentData in class SocketIOExceptionpublic void setOOBInline(boolean on)
throws SocketException
setOOBInline in class SocketSocketExceptionpublic boolean getOOBInline()
throws SocketException
getOOBInline in class SocketSocketExceptionpublic void setSoTimeout(int timeout)
throws SocketException
setSoTimeout in class SocketSocketExceptionpublic int getSoTimeout()
throws SocketException
getSoTimeout in class SocketSocketExceptionpublic void setSendBufferSize(int size)
throws SocketException
setSendBufferSize in class SocketSocketExceptionpublic int getSendBufferSize()
throws SocketException
getSendBufferSize in class SocketSocketExceptionpublic void setReceiveBufferSize(int size)
throws SocketException
setReceiveBufferSize in class SocketSocketExceptionpublic int getReceiveBufferSize()
throws SocketException
getReceiveBufferSize in class SocketSocketExceptionpublic void setKeepAlive(boolean on)
throws SocketException
setKeepAlive in class SocketSocketExceptionpublic boolean getKeepAlive()
throws SocketException
getKeepAlive in class SocketSocketExceptionpublic void setTrafficClass(int tc)
throws SocketException
setTrafficClass in class SocketSocketExceptionpublic int getTrafficClass()
throws SocketException
getTrafficClass in class SocketSocketExceptionpublic void setReuseAddress(boolean on)
throws SocketException
setReuseAddress in class SocketSocketExceptionpublic boolean getReuseAddress()
throws SocketException
getReuseAddress in class SocketSocketExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class SocketIOExceptionpublic void shutdownInput()
throws IOException
shutdownInput in class SocketIOExceptionpublic void shutdownOutput()
throws IOException
shutdownOutput in class SocketIOExceptionpublic boolean isConnected()
isConnected in class Socketpublic boolean isInputShutdown()
isInputShutdown in class Socketpublic boolean isOutputShutdown()
isOutputShutdown in class Socketpublic void setPerformancePreferences(int connectionTime,
int latency,
int bandwidth)
setPerformancePreferences in class Socketpublic Socket getProxySocket()
Copyright © 2015. All rights reserved.