_socket

func

getaddrinfo(host, port [, family, socktype, proto, flags])

(family, socktype, proto, canonname, sockaddr)

gethostbyaddr (name, aliaslist, addresslist)

gethostbyname address

gethostbyname_ex (name, aliaslist, addresslist)

host_to_net_

htonl(integer)

htons(integer)

ntohl(integer)

ntohs(integer)

inet_aton(string)

inet_ntoa(packed_ip)

setdefaulttimeout

_socket.socket

accept() -- accept a connection, returning new socket and client address
bind(addr) -- bind the socket to a local address
close() -- close the socket
connect(addr) -- connect the socket to a remote address
connect_ex(addr) -- connect, return an error code instead of an exception
dup() -- return a new socket object identical to the current one [*]
fileno() -- return underlying file descriptor
getpeername() -- return remote address [*]
getsockname() -- return local address
getsockopt(level, optname[, buflen]) -- get socket options
gettimeout() -- return timeout or None
listen(n) -- start listening for incoming connections
makefile([mode, [bufsize]]) -- return a file object for the socket [*]
recv(buflen[, flags]) -- receive data
recv_into(buffer[, nbytes[, flags]]) -- receive data (into a buffer)
recvfrom(buflen[, flags]) -- receive data and sender's address
recvfrom_into(buffer[, nbytes, [, flags])
  -- receive data and sender's address (into a buffer)
sendall(data[, flags]) -- send all data
send(data[, flags]) -- send data, may not send all of it
sendto(data[, flags], addr) -- send data to a given address
setblocking(0 | 1) -- set or clear the blocking I/O flag
setsockopt(level, optname, value) -- set socket options
settimeout(None | float) -- set or clear the timeout
shutdown(how) -- shut down traffic in one or both directions

 [*] not available on all platforms!

socket.socket

是基于_socket.socket的包装

def dup(self):
    """dup() -> socket object

    Return a new socket object connected to the same system resource."""
    return _socketobject(_sock=self._sock)

def 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."""
    return _fileobject(self._sock, mode, bufsize)

你可能感兴趣的:(_socket)