Lines Matching defs:socket

5 This module provides an interface to Berkeley socket IPC.
14 for by socket.py).
18 - socket.error: exception raised for socket specific errors, alias for OSError
19 - socket.gaierror: exception raised for getaddrinfo/getnameinfo errors,
20 a subclass of socket.error
21 - socket.herror: exception raised for gethostby* errors,
22 a subclass of socket.error
23 - socket.gethostbyname(hostname) --> host IP address (string: 'dd.dd.dd.dd')
24 - socket.gethostbyaddr(IP address) --> (hostname, [alias, ...], [IP addr, ...])
25 - socket.gethostname() --> host name (string: 'spam' or 'spam.domain.com')
26 - socket.getprotobyname(protocolname) --> protocol number
27 - socket.getservbyname(servicename[, protocolname]) --> port number
28 - socket.getservbyport(portnumber[, protocolname]) --> service name
29 - socket.socket([family[, type [, proto, fileno]]]) --> new socket object
30 (fileno specifies a pre-existing socket file descriptor)
31 - socket.socketpair([family[, type [, proto]]]) --> (socket, socket)
32 - socket.ntohs(16 bit value) --> new int object
33 - socket.ntohl(32 bit value) --> new int object
34 - socket.htons(16 bit value) --> new int object
35 - socket.htonl(32 bit value) --> new int object
36 - socket.getaddrinfo(host, port [, family, type, proto, flags])
38 - socket.getnameinfo(sockaddr, flags) --> (host, port)
39 - socket.AF_INET, socket.SOCK_STREAM, etc.: constants from <socket.h>
40 - socket.has_ipv6: boolean value indicating if IPv6 is supported
41 - socket.inet_aton(IP address) -> 32-bit packed IP representation
42 - socket.inet_ntoa(packed IP) -> IP address string
43 - socket.getdefaulttimeout() -> None | float
44 - socket.setdefaulttimeout(None | float)
45 - socket.if_nameindex() -> list of tuples (if_index, if_name)
46 - socket.if_nametoindex(name) -> corresponding interface index
47 - socket.if_indextoname(index) -> corresponding interface name
48 - an internet socket address is a pair (hostname, port)
52 - a UNIX domain socket address is a string specifying the pathname
53 - an AF_PACKET socket address is a tuple containing a string
58 - an AF_QIPCRTR socket address is a (node, port) tuple where the
60 - an AF_TIPC socket address is expressed as
82 - names starting with sock_ are socket object methods
93 // Issue #35569: Expose RFC 3542 socket options.
119 "socket(family=AF_INET, type=SOCK_STREAM, proto=0) -> socket object\n\
120 socket(family=-1, type=-1, proto=-1, fileno=None) -> socket object\n\
122 Open a socket of the given type. The family argument specifies the\n\
125 or datagram (SOCK_DGRAM) socket. The protocol argument defaults to 0,\n\
127 The socket is created as non-inheritable.\n\
132 A socket object represents one endpoint of a network connection.\n\
134 Methods of socket objects (keyword arguments not allowed):\n\
136 _accept() -- accept connection, returning new socket fd and client address\n\
137 bind(addr) -- bind the socket to a local address\n\
138 close() -- close the socket\n\
139 connect(addr) -- connect the socket to a remote address\n\
141 dup() -- return a new socket fd duplicated from fileno()\n\
145 getsockopt(level, optname[, buflen]) -- get socket options\n\
157 getblocking() -- return True if socket is blocking, False if non-blocking\n\
158 setsockopt(level, optname, value[, optlen]) -- set socket options\n\
220 #include <sys/socket.h>
243 #include <sys/socket.h>
250 /* Generic socket object definitions and includes */
335 class _socket.socket "PySocketSockObject *" "&sock_type"
400 * _SS_ALIGNSIZE is defined in sys/socket.h by 6.5.21,
533 /* A forward reference to the socket type object.
559 /* Can we call select() with this socket without a buffer overrun? */
569 PyErr_SetString(PyExc_OSError, "unable to select on socket");
673 /* Function to perform the setting of socket blocking mode
746 /* Guard against closed socket */
756 /* On Windows, the socket becomes writable on connection success,
758 socket becomes writable on connection success or on connection
793 /* On Windows, the socket becomes writable on connection success,
795 socket becomes writable on connection success or on connection
800 /* See if the socket is ready */
818 /* Call a socket function.
826 If the socket has a timeout, wait until the socket is ready before calling
827 the function: wait until the socket is writable if writing is nonzero, wait
828 until the socket received data otherwise.
830 If the socket function is interrupted by a signal (failed with EINTR): retry
835 sock_call_ex() must be called with the GIL held. The socket function is
857 /* For connect(), poll even for blocking socket. The connection
913 /* the socket is ready */
950 For example, select() could indicate a socket is ready for
954 Loop on select() to recheck for socket readiness. */
976 /* Initialize a new socket object. */
991 on some OSes as part of socket.type. We want to reset them here,
992 to make socket.type be set to the same value on all platforms.
1024 /* Create a new socket object.
1312 /* Create an object representing the given socket address,
1322 /* No address -- may be recvfrom() from known socket */
1673 /* Parse a socket address argument according to the socket object's
2405 /* Get the address length according to the socket object's address family.
2804 Wait for an incoming connection. Return a new socket file descriptor\n\
2834 Set the socket to blocking (flag is true) or non-blocking (false).\n\
2839 Returns True if socket is in blocking mode,
2856 Returns True if socket is in blocking mode, or False if it\n\
2917 /* Blocking mode for a Python socket object means that operations
2920 `TimeoutError` or `socket.error` errors. When timeout is `None`,
2922 number, the FD is in a non-blocking mode, and socket ops are
2927 This table summarizes all states in which the socket object and
2947 Set a timeout on socket operations. 'timeout' can be a float,\n\
2953 Returns the timeout associated with a socket. */
2969 Returns the timeout in seconds (float) associated with socket\n\
2970 operations. A timeout of None indicates that timeouts on socket\n\
3036 "socket option is larger than %i bytes",
3060 Set a socket option. See the Unix manual for level and option.\n\
3132 Get a socket option. See the Unix manual for level and option.\n\
3151 if (PySys_Audit("socket.bind", "OO", s, addro) < 0) {
3166 Bind the socket to a local address. For IP sockets, the address is a\n\
3205 Close the socket. It cannot be used after this call.");
3218 Close the socket object without closing the underlying file descriptor.\n\
3255 /* connect() succeeded, the socket is connected */
3270 If the socket is blocking or has a timeout, wait until the
3274 If the socket is non-blocking, raise InterruptedError. The caller is
3296 /* socket.connect() raises an exception on error */
3302 /* socket.connect_ex() returns the error code on error */
3323 if (PySys_Audit("socket.connect", "OO", s, addro) < 0) {
3337 Connect the socket to a remote address. For IP sockets, the address\n\
3354 if (PySys_Audit("socket.connect", "OO", s, addro) < 0) {
3384 Return the integer file descriptor of the socket.");
3584 Receive up to buffersize bytes from the socket. For the optional flags\n\
3646 a new string. Receive up to buffersize bytes from the socket. If buffersize\n\
3879 ignored" when the socket is connected (Linux fills them in
4042 socket. The ancbufsize argument sets the size in bytes of the\n\
4059 details. If the receiving socket is unconnected, address is the\n\
4060 address of the sending socket, if available; otherwise, its value is\n\
4131 Receive normal data and ancillary data from the socket, scattering the\n\
4153 documentation for details. If the receiving socket is unconnected,\n\
4154 address is the address of the sending socket, if available; otherwise,\n\
4216 Send a data string to the socket. For the optional flags\n\
4294 Send a data string to the socket. For the optional flags\n\
4370 if (PySys_Audit("socket.sendto", "OO", s, addro) < 0) {
4506 if (PySys_Audit("socket.sendmsg", "OO", s, addr_arg) < 0) {
4512 if (PySys_Audit("socket.sendmsg", "OO", s, Py_None) < 0) {
4661 Send normal and ancillary data to the socket, gathering the\n\
4839 operation socket.");
4865 Shut down the reading side of the socket (flag == SHUT_RD), the writing side\n\
4866 of the socket (flag == SHUT_WR), or both ends (flag == SHUT_RDWR).");
4919 Control the socket with WSAIoctl syscall. Currently supported 'cmd' values are\n\
4920 SIO_RCVALL: 'option' must be one of the socket.RCVALL_* constants.\n\
4946 Share the socket with another process. The target process id\n\
4948 process. There the shared socket can be instantiated by calling\n\
4949 socket.fromshare().");
4954 /* List of methods for socket objects */
5050 {"family", T_INT, offsetof(PySocketSockObject, sock_family), READONLY, "the socket family"},
5051 {"type", T_INT, offsetof(PySocketSockObject, sock_type), READONLY, "the socket type"},
5052 {"proto", T_INT, offsetof(PySocketSockObject, sock_proto), READONLY, "the socket protocol"},
5057 {"timeout", (getter)sock_gettimeout, NULL, PyDoc_STR("the socket timeout")},
5061 /* Deallocate a socket object in response to the last Py_DECREF().
5081 /* Only close the socket *after* logging the ResourceWarning warning
5082 to allow the logger to call socket methods like
5083 socket.getsockname(). If the socket is closed before, socket
5123 "the socket descriptor in decimal");
5130 "<socket object, fd=%ld, family=%d, type=%d, proto=%d>",
5137 /* Create a new, uninitialized socket object. */
5154 /* Initialize a new socket object. */
5157 /* socket() and socketpair() fail with EINVAL on Linux kernel older
5158 * than 2.6.27 if SOCK_CLOEXEC flag is set in the socket type. */
5165 #define socket stub_socket
5167 socket(int domain, int type, int protocol)
5175 _socket.socket.__init__ as sock_initobj
5203 if (PySys_Audit("socket.__new__", "Oiii",
5211 /* recreate a socket that was duplicated */
5216 "socket descriptor string has wrong size, "
5222 if (PySys_Audit("socket.__new__", "Oiii", self,
5255 /* validate that passed file descriptor is valid and a socket. */
5267 /* getsockname() on an unbound socket is an error on Windows.
5268 Invalid descriptor and not a socket is same error code.
5339 fd = socket(family, type, proto);
5343 fd = socket(family, type, proto);
5364 fd = socket(family, type | SOCK_CLOEXEC, proto);
5372 fd = socket(family, type, proto);
5379 fd = socket(family, type, proto);
5404 /* Type object for socket objects. */
5408 "_socket.socket", /* tp_name */
5465 if (PySys_Audit("socket.gethostname", NULL) < 0) {
5549 if (PySys_Audit("socket.sethostname", "(O)", hnobj) < 0) {
5579 if (PySys_Audit("socket.gethostbyname", "O", args) < 0) {
5769 if (PySys_Audit("socket.gethostbyname", "O", args) < 0) {
5851 if (PySys_Audit("socket.gethostbyaddr", "O", args) < 0) {
5927 if (PySys_Audit("socket.getservbyname", "ss", name, proto) < 0) {
5970 if (PySys_Audit("socket.getservbyport", "is", port, proto) < 0) {
6044 Close an integer socket file descriptor. This is like os.close(), but for\n\
6045 sockets; on some platforms os.close() won't work for socket file descriptors.");
6048 /* dup() function for socket fds */
6079 /* On UNIX, dup can be used to duplicate the file descriptor of a socket */
6094 Duplicate an integer socket file descriptor. This is like os.dup(), but for\n\
6095 sockets; on some platforms os.dup() won't work for socket file descriptors.");
6101 Arguments as for socket() except the default family is AF_UNIX if
6128 /* Create a pair of socket fds */
6180 "socketpair([family[, type [, proto]]]) -> (socket object, socket object)\n\
6182 Create a pair of socket objects from the sockets returned by the platform\n\
6184 The arguments are the same as for socket() except the default family is\n\
6315 /* socket.inet_aton() and socket.inet_ntoa() functions. */
6600 if (PySys_Audit("socket.getaddrinfo", "OOiii",
6698 if (PySys_Audit("socket.getnameinfo", "(O)", sa) < 0) {
6784 Returns the default timeout in seconds (float) for new socket objects.\n\
6785 A value of None indicates that new socket objects have no timeout.\n\
6786 When the socket module is first imported, the default is None.");
6804 Set the default timeout in seconds (float) for new socket objects.\n\
6805 A value of None indicates that new socket objects have no timeout.\n\
6806 When the socket module is first imported, the default is None.");
7200 "socket.py" which implements some additional functionality.
7208 "Implementation module for socket operations.\n\
7210 See the socket module for documentation.");
7245 socket_herror = PyErr_NewException("socket.herror",
7251 socket_gaierror = PyErr_NewException("socket.gaierror", PyExc_OSError,
7264 if (PyModule_AddObject(m, "socket",
7594 /* We have incomplete socket support. */
7918 /* J1939 socket options */
8235 /* Additional IPV6 socket options, defined in RFC 3493 */
8239 /* Advanced IPV6 socket options, from RFC 3542 */