Markdown Format | JSON API | MCP Server Tool
Help on class socket in socket: socket.socket = class socket(_socket.socket) | socket.socket(family=-1, type=-1, proto=-1, fileno=None) | | A subclass of _socket.socket adding the makefile() method. | | Method resolution order: | socket | _socket.socket | builtins.object | | Methods defined here: | | __enter__(self) | | __exit__(self, *args) | | __getstate__(self) | | __init__(self, family=-1, type=-1, proto=-1, fileno=None) | Initialize self. See help(type(self)) for accurate signature. | | __repr__(self) | Wrap __repr__() to reveal the real class name and socket | address(es). | | 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). | | close(self) | close() | | Close the socket. It cannot be used after this call. | | detach(self) | 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(self) | dup() -> socket object | | Duplicate the socket. Return a new socket object connected to the same | system resource. The new socket is non-inheritable. | | get_inheritable(self) | Get the inheritable flag of the socket | | makefile(self, mode='r', buffering=None, *, encoding=None, errors=None, newline=None) | makefile(...) -> an I/O stream connected to the socket | | The arguments are as for io.open() after the filename, except the only | supported mode values are 'r' (default), 'w' and 'b'. | | sendfile(self, file, offset=0, count=None) | 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. | | set_inheritable(self, inheritable) | Set the inheritable flag of the socket | | ---------------------------------------------------------------------- | Readonly properties defined here: | | family | Read-only access to the address family for this socket. | | type | Read-only access to the socket type. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from _socket.socket: | | __del__(...) | | __getattribute__(self, name, /) | Return getattr(self, name). | | 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 [,addr]]]) | | connect(...) | connect(address) | | Connect the socket to a remote address. For IP sockets, the address | is a pair (host, port). | | 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. | | fileno(...) | fileno() -> integer | | Return the integer file descriptor of the socket. | | getblocking(...) | getblocking() | | Returns True if socket is in blocking mode, or False if it | is in non-blocking mode. | | getpeername(...) | getpeername() -> address info | | Return the address of the remote endpoint. For IP sockets, the address | info is a pair (hostaddr, port). | | getsockname(...) | getsockname() -> address info | | Return the address of the local endpoint. The format depends on the | address family. For IPv4 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 seconds (float) 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. If backlog is specified, it 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. If not specified, a default reasonable value is chosen. | | recv(...) | recv(buffersize[, flags]) -> data | | Receive up to buffersize bytes from the socket. For the optional flags | argument, see the Unix manual. When no data is available, block until | at least one byte is available or until the remote end is closed. When | the remote end is closed and all data is read, return the empty string. | | recv_into(...) | recv_into(buffer, [nbytes[, flags]]) -> nbytes_read | | A version of recv() that stores its data into a buffer rather than creating | a new string. Receive up to buffersize bytes from the socket. If buffersize | is not specified (or 0), receive up to the size available in the given buffer. | | See recv() for documentation about the flags. | | recvfrom(...) | recvfrom(buffersize[, flags]) -> (data, address info) | | Like recv(buffersize, flags) but also return the sender's address info. | | recvfrom_into(...) | recvfrom_into(buffer[, nbytes[, flags]]) -> (nbytes, address info) | | Like recv_into(buffer[, nbytes[, flags]]) but also return the sender's address info. | | recvmsg(...) | recvmsg(bufsize[, ancbufsize[, flags]]) -> (data, ancdata, msg_flags, address) | | Receive normal data (up to bufsize bytes) and ancillary data from the | socket. The ancbufsize argument sets the size in bytes of the | internal buffer used to receive the ancillary data; it defaults to 0, | meaning that no ancillary data will be received. Appropriate buffer | sizes for ancillary data can be calculated using CMSG_SPACE() or | CMSG_LEN(), and items which do not fit into the buffer might be | truncated or discarded. The flags argument defaults to 0 and has the | same meaning as for recv(). | | The return value is a 4-tuple: (data, ancdata, msg_flags, address). | The data item is a bytes object holding the non-ancillary data | received. The ancdata item is a list of zero or more tuples | (cmsg_level, cmsg_type, cmsg_data) representing the ancillary data | (control messages) received: cmsg_level and cmsg_type are integers | specifying the protocol level and protocol-specific type respectively, | and cmsg_data is a bytes object holding the associated data. The | msg_flags item is the bitwise OR of various flags indicating | conditions on the received message; see your system documentation for | details. If the receiving socket is unconnected, address is the | address of the sending socket, if available; otherwise, its value is | unspecified. | | If recvmsg() raises an exception after the system call returns, it | will first attempt to close any file descriptors received via the | SCM_RIGHTS mechanism. | | recvmsg_into(...) | recvmsg_into(buffers[, ancbufsize[, flags]]) -> (nbytes, ancdata, msg_flags, address) | | Receive normal data and ancillary data from the socket, scattering the | non-ancillary data into a series of buffers. The buffers argument | must be an iterable of objects that export writable buffers | (e.g. bytearray objects); these will be filled with successive chunks | of the non-ancillary data until it has all been written or there are | no more buffers. The ancbufsize argument sets the size in bytes of | the internal buffer used to receive the ancillary data; it defaults to | 0, meaning that no ancillary data will be received. Appropriate | buffer sizes for ancillary data can be calculated using CMSG_SPACE() | or CMSG_LEN(), and items which do not fit into the buffer might be | truncated or discarded. The flags argument defaults to 0 and has the | same meaning as for recv(). | | The return value is a 4-tuple: (nbytes, ancdata, msg_flags, address). | The nbytes item is the total number of bytes of non-ancillary data | written into the buffers. The ancdata item is a list of zero or more | tuples (cmsg_level, cmsg_type, cmsg_data) representing the ancillary | data (control messages) received: cmsg_level and cmsg_type are | integers specifying the protocol level and protocol-specific type | respectively, and cmsg_data is a bytes object holding the associated | data. The msg_flags item is the bitwise OR of various flags | indicating conditions on the received message; see your system | documentation for details. If the receiving socket is unconnected, | address is the address of the sending socket, if available; otherwise, | its value is unspecified. | | If recvmsg_into() raises an exception after the system call returns, | it will first attempt to close any file descriptors received via the | SCM_RIGHTS mechanism. | | send(...) | send(data[, flags]) -> count | | Send a data string to the socket. For the optional flags | argument, see the Unix manual. Return the number of bytes | sent; this may be less than len(data) if the network is busy. | | sendall(...) | sendall(data[, flags]) | | Send a data string to the socket. For the optional flags | argument, see the Unix manual. This calls send() repeatedly | until all data is sent. If an error occurs, it's impossible | to tell how much data has been sent. | | sendmsg(...) | sendmsg(buffers[, ancdata[, flags[, address]]]) -> count | | Send normal and ancillary data to the socket, gathering the | non-ancillary data from a series of buffers and concatenating it into | a single message. The buffers argument specifies the non-ancillary | data as an iterable of bytes-like objects (e.g. bytes objects). | The ancdata argument specifies the ancillary data (control messages) | as an iterable of zero or more tuples (cmsg_level, cmsg_type, | cmsg_data), where cmsg_level and cmsg_type are integers specifying the | protocol level and protocol-specific type respectively, and cmsg_data | is a bytes-like object holding the associated data. The flags | argument defaults to 0 and has the same meaning as for send(). If | address is supplied and not None, it sets a destination address for | the message. The return value is the number of bytes of non-ancillary | data sent. | | sendmsg_afalg(...) | sendmsg_afalg([msg], *, op[, iv[, assoclen[, flags=MSG_MORE]]]) | | Set operation mode, IV and length of associated data for an AF_ALG | operation socket. | | sendto(...) | sendto(data[, flags], address) -> count | | Like send(data, flags) but allows specifying the destination address. | For IP sockets, the address is a pair (hostaddr, port). | | 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: int) | setsockopt(level, option, value: buffer) | setsockopt(level, option, None, optlen: int) | | Set a socket option. See the Unix manual for level and option. | The value argument can either be an integer, a string buffer, or | None, optlen. | | 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). | | ---------------------------------------------------------------------- | Static methods inherited from _socket.socket: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from _socket.socket: | | proto | the socket protocol | | timeout | the socket timeout
Generated by phpMan Author: Che Dong Under GNU General Public License
2026-06-02 06:19 @216.73.216.198 CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)