| |
- exceptions.Exception(exceptions.BaseException)
-
- ProxyError
-
- GeneralProxyError
- HTTPError
- Socks4Error
- Socks5AuthError
- Socks5Error
- socket._socketobject(__builtin__.object)
-
- socksocket
class socksocket(socket._socketobject) |
|
socksocket([family[, type[, proto]]]) -> socket object
Open a SOCKS enabled socket. The parameters are the same as
those of the standard socket init. In order for SOCKS to work,
you must specify family=AF_INET, type=SOCK_STREAM and proto=0. |
|
- Method resolution order:
- socksocket
- socket._socketobject
- __builtin__.object
Methods defined here:
- __init__(self, family=2, type=1, proto=0, _sock=None)
- connect(self, destpair)
- connect(self, despair)
Connects to the specified destination through a proxy.
destpar - A tuple of the IP/DNS address and the port number.
(identical to socket's connect).
To select the proxy server use setproxy().
- getpeername(self)
- getpeername() -> address info
Returns the IP address and port number of the destination
machine (note: getproxypeername returns the proxy)
- getproxypeername(self)
- getproxypeername() -> address info
Returns the IP and port number of the proxy.
- getproxysockname(self)
- getsockname() -> address info
Returns the bound IP address and port number at the proxy.
- sendall(self, content, *args)
- override socket.socket.sendall method to rewrite the header
for non-tunneling proxies if needed
- setproxy(self, proxytype=None, addr=None, port=None, rdns=True, username=None, password=None)
- setproxy(proxytype, addr[, port[, rdns[, username[, password]]]])
Sets the proxy to be used.
proxytype - The type of the proxy to be used. Three types
are supported: PROXY_TYPE_SOCKS4 (including socks4a),
PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP
addr - The address of the server (IP or DNS).
port - The port of the server. Defaults to 1080 for SOCKS
servers and 8080 for HTTP proxy servers.
rdns - Should DNS queries be preformed on the remote side
(rather than the local side). The default is True.
Note: This has no effect with SOCKS4 servers.
username - Username to authenticate with to the server.
The default is no authentication.
password - Password to authenticate with to the server.
Only relevant when username is also provided.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
Methods inherited from socket._socketobject:
- accept(self)
- accept() -> (socket object, address info)
Wait for an incoming connection. Return a new socket representing the
connection, and the address of the client. For IP sockets, the address
info is a pair (hostaddr, port).
- bind(...)
- bind(address)
Bind the socket to a local address. For IP sockets, the address is a
pair (host, port); the host must refer to the local host. For raw packet
sockets the address is a tuple (ifname, proto [,pkttype [,hatype]])
- close(self, _closedsocket=<class 'socket._closedsocket'>, _delegate_methods=('recv', 'recvfrom', 'recv_into', 'recvfrom_into', 'send', 'sendto'), setattr=<built-in function setattr>)
- close()
Close the socket. It cannot be used after this call.
- connect_ex(...)
- connect_ex(address) -> errno
This is like connect(address), but returns an error code (the errno value)
instead of raising an exception when an error occurs.
- dup(self)
- dup() -> socket object
Return a new socket object connected to the same system resource.
- fileno(...)
- fileno() -> integer
Return the integer file descriptor of the socket.
- getsockname(...)
- getsockname() -> address info
Return the address of the local endpoint. For IP sockets, the address
info is a pair (hostaddr, port).
- getsockopt(...)
- getsockopt(level, option[, buffersize]) -> value
Get a socket option. See the Unix manual for level and option.
If a nonzero buffersize argument is given, the return value is a
string of that length; otherwise it is an integer.
- gettimeout(...)
- gettimeout() -> timeout
Returns the timeout in floating seconds associated with socket
operations. A timeout of None indicates that timeouts on socket
operations are disabled.
- listen(...)
- listen(backlog)
Enable a server to accept connections. The backlog argument must be at
least 0 (if it is lower, it is set to 0); it specifies the number of
unaccepted connections that the system will allow before refusing new
connections.
- makefile(self, mode='r', bufsize=-1)
- makefile([mode[, bufsize]]) -> file object
Return a regular file object corresponding to the socket. The mode
and bufsize arguments are as for the built-in open() function.
- setblocking(...)
- setblocking(flag)
Set the socket to blocking (flag is true) or non-blocking (false).
setblocking(True) is equivalent to settimeout(None);
setblocking(False) is equivalent to settimeout(0.0).
- setsockopt(...)
- setsockopt(level, option, value)
Set a socket option. See the Unix manual for level and option.
The value argument can either be an integer or a string.
- settimeout(...)
- settimeout(timeout)
Set a timeout on socket operations. 'timeout' can be a float,
giving in seconds, or None. Setting a timeout of None disables
the timeout feature and is equivalent to setblocking(1).
Setting a timeout of zero is the same as setblocking(0).
- shutdown(...)
- shutdown(flag)
Shut down the reading side of the socket (flag == SHUT_RD), the writing side
of the socket (flag == SHUT_WR), or both ends (flag == SHUT_RDWR).
Data descriptors inherited from socket._socketobject:
- __weakref__
- list of weak references to the object (if defined)
- family
- the socket family
- proto
- the socket protocol
- recv
- recv_into
- recvfrom
- recvfrom_into
- send
- sendto
- type
- the socket type
| |