This is an extremely simple SOCKS socket class. To use it create an instance, and it will automatically connect to your destination through your SOCKS firewall.
At this point you can either apply socket methods directly to this object (optionally using the reader and writer attributes as input and output files), or you can directly operate on the sock attribute, which is the connected socket object.
Example:
# connect to foreign.host.com's http server via # socks-server.domain.com s = SOCKSSocket('socks-server.domain.com', 'foreign.host.com', 80) # get the index page s.writer.write('GET / ') s.writer.flush() # read the result print s.reader.read() # close the socket explicitly (this is unnecessary, but demonstrates # our direct access to the _real_ socket object. s.sock.close()
Public-vars:
A standard python socket object instance.
Input file object for the socket
Output file object for the socket
def __getattr__(self, attr):
def __init__(self, socksServer, foreignServer, foreignPort, socksPort = 1080, userId = '', ):