Create a socket object.
Lightweight wrapper around the standard Berkeley sockets interface.
Classes
_class socket(object)
_let x = socket(family=AF_INET,type=SOCK_STREAM,proto=0)
Creates a new socket object for the given address family and type.
_socket.accept()
Accept a connection on a listening socket.
Accepts one connection and returns a two-tuple with a new socket object and the address of the remote host.
_socket.bind(address)
Bind a socket to an address.
The format of address
varies by address family. For AF_INET
, address
should be a two-tuple of a string domain name and integer port number.
_socket.connect(address)
_socket.fileno()
Get the file descriptor number for the underlying socket.
_socket.listen(backlog=0)
Set a bound socket to listen.
Begin listening on a bound socket, keeping backlog
connections in a queue.
_socket.recv(bufsize,[flags])
Receive data from a connected socket.
Receive up to bufsize
bytes of data, which is returned as a bytes object.
_socket.send(buf,[flags])
Send data to a connected socket.
Send the data in the bytes object buf
to the socket. Returns the number of bytes written to the socket.
_socket.sendto(buf,[flags],addr)
Send data to an socket with a particular destination.
Send the data in the bytes object buf
to the socket. Returns the number of bytes written to the socket.
_socket.setsockopt(level,optname,value)
_socket.shutdown(how)
Shut down an active socket.
Gracefully closes an open socket.
_property socket.family
_property socket.proto
_property socket.type
Functions
_htons()
Exceptions
_class SocketError(BaseException)
Raised on faults from socket functions.