gevent._socket3
– Python 3 socket module¶Python 3 socket module.
alias of gevent._socket3.socket
Bases: gevent._socketcommon.SocketMixin
gevent socket.socket for Python 3.
This object should have the same API as the standard library socket linked to above. Not all methods are specifically documented here; when they are they may point out a difference to be aware of or may document a method the standard library does not.
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).
Connect to address.
Changed in version 20.6.0: If the host part of the address includes an IPv6 scope ID,
it will be used instead of ignored, if the platform supplies
socket.inet_pton()
.
Close the socket object without closing the underlying file descriptor. The object cannot be used after this call; when the real file descriptor is closed, the number that was previously used here may be reused. The fileno() method, after this call, will return an invalid socket id.
The previous descriptor is returned.
Changed in version 1.5: Also immediately drop any native event loop resources.
Returns whether the socket will approximate blocking behaviour.
New in version 1.3a2: Added in Python 3.7.
Return an I/O stream connected to the socket
The arguments are as for io.open() after the filename, except the only mode characters supported are ‘r’, ‘w’ and ‘b’. The semantics are similar too.
Send a file until EOF is reached by using high-performance os.sendfile() and return the total number of bytes which were sent. file must be a regular file object opened in binary mode. If os.sendfile() is not available (e.g. Windows) or file is not a regular file socket.send() will be used instead. offset tells from where to start reading the file. If specified, count is the total number of bytes to transmit as opposed to sending the file until EOF is reached. File position is updated on return or also in case of error in which case file.tell() can be used to figure out the number of bytes which were sent. The socket must be of SOCK_STREAM type. Non-blocking sockets are not supported.
New in version 1.1rc4: Added in Python 3.5, but available under all Python 3 versions in gevent.
Connect to address and return the gevent.socket.socket
object.
Convenience function. Connect to address (a 2-tuple (host,
port)
) and return the socket object. Passing the optional
timeout parameter will set the timeout on the socket instance
before attempting to connect. If no timeout is supplied, the
global default timeout setting returned by
getdefaulttimeout()
is used. If source_address is set it
must be a tuple of (host, port) for the socket to bind as a source
address before making the connection. A host of ‘’ or port 0 tells
the OS to use the default.
Changed in version 20.6.0: If the host part of the address includes an IPv6 scope ID,
it will be used instead of ignored, if the platform supplies
socket.inet_pton()
.
Create a socket object from a duplicate of the given file descriptor. The remaining arguments are the same as for socket().
Resolve host and port into list of address info entries.
Translate the host/port argument into a sequence of 5-tuples that contain all the necessary arguments for creating a socket connected to that service. host is a domain name, a string representation of an IPv4/v6 address or None. port is a string service name such as ‘http’, a numeric port number or None. By passing None as the value of host and port, you can pass NULL to the underlying C API.
The family, type and proto arguments can be optionally specified in order to narrow the list of addresses returned. Passing zero as a value for each of these arguments selects the full range of results.
See also
Get fully qualified domain name from name.
An empty argument is interpreted as meaning the local host.
First the hostname returned by gethostbyaddr() is checked, then possibly existing aliases. In case no FQDN is available, hostname from gethostname() is returned.
Return the true host name, a list of aliases, and a list of IP addresses, for a host. The host argument is a string giving a host name or IP number.
See also
Return the IP address (a string of the form ‘255.255.255.255’) for a host.
See also
Return the true host name, a list of aliases, and a list of IP addresses, for a host. The host argument is a string giving a host name or IP number. Resolve host and port into list of address info entries.
See also
Create a pair of socket objects from the sockets returned by the platform socketpair() function. The arguments are the same as for socket() except the default family is AF_UNIX if defined on the platform; otherwise, the default is AF_INET.
Changed in version 1.2: All Python 3 versions on Windows supply this function (natively supplied by Python 3.5 and above).
Next page: gevent._socket2
– Python 2 socket module