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, toString
public 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
SocksException
IOException
public 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 Socket
SocksException
IOException
public void connect(SocketAddress endpoint, int timeout) throws SocksException, IOException
connect
in class Socket
SocksException
IOException
public InputStream getInputStream() throws IOException
getInputStream
in class Socket
IOException
public OutputStream getOutputStream() throws IOException
getOutputStream
in class Socket
IOException
public void bind(SocketAddress bindpoint) throws IOException
bind
in class Socket
IOException
public InetAddress getInetAddress()
getInetAddress
in class Socket
public InetAddress getLocalAddress()
getLocalAddress
in class Socket
public int getLocalPort()
getLocalPort
in class Socket
public SocketAddress getRemoteSocketAddress()
getRemoteSocketAddress
in class Socket
public SocketAddress getLocalSocketAddress()
getLocalSocketAddress
in class Socket
public SocketChannel getChannel()
getChannel
in class Socket
public void setTcpNoDelay(boolean on) throws SocketException
setTcpNoDelay
in class Socket
SocketException
public boolean getTcpNoDelay() throws SocketException
getTcpNoDelay
in class Socket
SocketException
public void setSoLinger(boolean on, int linger) throws SocketException
setSoLinger
in class Socket
SocketException
public int getSoLinger() throws SocketException
getSoLinger
in class Socket
SocketException
public void sendUrgentData(int data) throws IOException
sendUrgentData
in class Socket
IOException
public void setOOBInline(boolean on) throws SocketException
setOOBInline
in class Socket
SocketException
public boolean getOOBInline() throws SocketException
getOOBInline
in class Socket
SocketException
public void setSoTimeout(int timeout) throws SocketException
setSoTimeout
in class Socket
SocketException
public int getSoTimeout() throws SocketException
getSoTimeout
in class Socket
SocketException
public void setSendBufferSize(int size) throws SocketException
setSendBufferSize
in class Socket
SocketException
public int getSendBufferSize() throws SocketException
getSendBufferSize
in class Socket
SocketException
public void setReceiveBufferSize(int size) throws SocketException
setReceiveBufferSize
in class Socket
SocketException
public int getReceiveBufferSize() throws SocketException
getReceiveBufferSize
in class Socket
SocketException
public void setKeepAlive(boolean on) throws SocketException
setKeepAlive
in class Socket
SocketException
public boolean getKeepAlive() throws SocketException
getKeepAlive
in class Socket
SocketException
public void setTrafficClass(int tc) throws SocketException
setTrafficClass
in class Socket
SocketException
public int getTrafficClass() throws SocketException
getTrafficClass
in class Socket
SocketException
public void setReuseAddress(boolean on) throws SocketException
setReuseAddress
in class Socket
SocketException
public boolean getReuseAddress() throws SocketException
getReuseAddress
in class Socket
SocketException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Socket
IOException
public void shutdownInput() throws IOException
shutdownInput
in class Socket
IOException
public void shutdownOutput() throws IOException
shutdownOutput
in class Socket
IOException
public boolean isConnected()
isConnected
in class Socket
public boolean isInputShutdown()
isInputShutdown
in class Socket
public boolean isOutputShutdown()
isOutputShutdown
in class Socket
public void setPerformancePreferences(int connectionTime, int latency, int bandwidth)
setPerformancePreferences
in class Socket
public Socket getProxySocket()
Copyright © 2015. All rights reserved.