gevent._socket3– Python 3 socket module¶
create_connection(address, timeout=<object object>, source_address=None)¶
Connect to address and return the socket object.
Convenience function. Connect to address (a 2-tuple
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
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.
socket(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=0, fileno=None)¶
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.
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).
detach() → file descriptor¶
Close the socket object without closing the underlying file descriptor. The object cannot be used after this call, but the file descriptor can be reused for other purposes. The file descriptor is returned.
dup() → socket object¶
Return a new socket object connected to the same system resource.
Get the inheritable flag of the socket
New in version 1.1rc4: Added in Python 3.4
makefile(mode='r', buffering=None, *, encoding=None, errors=None, newline=None)¶
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.
sendfile(file[, offset[, count]]) → sent¶
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.
Set the inheritable flag of the socket
New in version 1.1rc4: Added in Python 3.4
fromfd(fd, family, type[, proto]) → socket object¶
Create a socket object from a duplicate of the given file descriptor. The remaining arguments are the same as for socket().
socketpair([family[, type[, proto]]]) -> (socket object, socket object)¶
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).
getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0)¶
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.
gethostbyname(host) → address¶
Return the IP address (a string of the form ‘255.255.255.255’) for a host.
gethostbyname_ex(host) -> (name, aliaslist, addresslist)¶
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.
gethostbyaddr(host) -> (name, aliaslist, addresslist)¶
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.
getnameinfo(sockaddr, flags) -> (host, port)¶
Get host and port for a sockaddr.
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.
gevent._socket2 – Python 2 socket module