#include "Python.h"#include "structmember.h"#include "socketmodule.h"#include <netdb.h>#include <arpa/inet.h>#include <fcntl.h>#include <stddef.h>#include "addrinfo.h"#include "getaddrinfo.c"#include "getnameinfo.c"Defines | |
| #define | ACQUIRE_GETADDRINFO_LOCK |
| #define | cppstring(x) #x |
| #define | freeaddrinfo fake_freeaddrinfo |
| #define | gai_strerror fake_gai_strerror |
| #define | getaddrinfo fake_getaddrinfo |
| #define | getnameinfo fake_getnameinfo |
| #define | INADDR_NONE (-1) |
| #define | IS_SELECTABLE(s) ((s)->sock_fd < FD_SETSIZE || s->sock_timeout <= 0.0) |
| #define | MAX(x, y) ((x) < (y) ? (y) : (x)) |
| #define | NI_MAXHOST 1025 |
| #define | NI_MAXSERV 32 |
| #define | O_NONBLOCK O_NDELAY |
| #define | offsetof(type, member) ((size_t)(&((type *)0)->member)) |
| #define | PySocket_BUILDING_SOCKET |
| #define | RELEASE_GETADDRINFO_LOCK |
| #define | SAS2SA(x) ((struct sockaddr *)(x)) |
| #define | SOCKETCLOSE close |
Functions | |
| static PyObject * | gethost_common (struct hostent *h, struct sockaddr *addr, int alen, int af) |
| static int | getsockaddrarg (PySocketSockObject *s, PyObject *args, struct sockaddr *addr_ret, int *len_ret) |
| static int | getsockaddrlen (PySocketSockObject *s, socklen_t *len_ret) |
| const char * | inet_ntop (int af, const void *src, char *dst, socklen_t size) |
| int | inet_pton (int af, const char *src, void *dst) |
| PyMODINIT_FUNC | init_socket (void) |
| PyMODINIT_FUNC | init_sockobject (PySocketSockObject *s, SOCKET_T fd, int family, int type, int proto) |
| static int | internal_connect (PySocketSockObject *s, struct sockaddr *addr, int addrlen, int *timeoutp) |
| static int | internal_select (PySocketSockObject *s, int writing) |
| static int | internal_setblocking (PySocketSockObject *s, int block) |
| static PyObject * | makeipaddr (struct sockaddr *addr, int addrlen) |
| static PyObject * | makesockaddr (int sockfd, struct sockaddr *addr, int addrlen, int proto) |
| static PySocketSockObject * | new_sockobject (SOCKET_T fd, int family, int type, int proto) |
| static int | os_init (void) |
| PyDoc_STRVAR (socket_doc,"Implementation module for socket operations.\n\ \n\ See the socket module for documentation.") | |
| PyDoc_STRVAR (setdefaulttimeout_doc,"setdefaulttimeout(timeout)\n\ \n\ Set the default timeout in floating seconds for new socket objects.\n\ A value of None indicates that new socket objects have no timeout.\n\ When the socket module is first imported, the default is None.") | |
| PyDoc_STRVAR (getdefaulttimeout_doc,"getdefaulttimeout() -> timeout\n\ \n\ Returns the default timeout in floating seconds for new socket objects.\n\ A value of None indicates that new socket objects have no timeout.\n\ When the socket module is first imported, the default is None.") | |
| PyDoc_STRVAR (getnameinfo_doc,"getnameinfo(sockaddr, flags) --> (host, port)\n\ \n\ Get host and port for a sockaddr.") | |
| PyDoc_STRVAR (getaddrinfo_doc,"getaddrinfo(host, port [, family, socktype, proto, flags])\n\ -> list of (family, socktype, proto, canonname, sockaddr)\n\ \n\ Resolve host and port into addrinfo struct.") | |
| PyDoc_STRVAR (inet_ntoa_doc,"inet_ntoa(packed_ip) -> ip_address_string\n\ \n\ Convert an IP address from 32-bit packed binary format to string format") | |
| PyDoc_STRVAR (inet_aton_doc,"inet_aton(string) -> packed 32-bit IP representation\n\ \n\ Convert an IP address in string format (123.45.67.89) to the 32-bit packed\n\ binary format used in low-level network functions.") | |
| PyDoc_STRVAR (htonl_doc,"htonl(integer) -> integer\n\ \n\ Convert a 32-bit integer from host to network byte order.") | |
| PyDoc_STRVAR (htons_doc,"htons(integer) -> integer\n\ \n\ Convert a 16-bit integer from host to network byte order.") | |
| PyDoc_STRVAR (ntohl_doc,"ntohl(integer) -> integer\n\ \n\ Convert a 32-bit integer from network to host byte order.") | |
| PyDoc_STRVAR (ntohs_doc,"ntohs(integer) -> integer\n\ \n\ Convert a 16-bit integer from network to host byte order.") | |
| PyDoc_STRVAR (fromfd_doc,"fromfd(fd, family, type[, proto]) -> socket object\n\ \n\ Create a socket object from a duplicate of the given\n\ file descriptor.\n\ The remaining arguments are the same as for socket().") | |
| PyDoc_STRVAR (getprotobyname_doc,"getprotobyname(name) -> integer\n\ \n\ Return the protocol number for the named protocol. (Rarely used.)") | |
| PyDoc_STRVAR (getservbyport_doc,"getservbyport(port[, protocolname]) -> string\n\ \n\ Return the service name from a port number and protocol name.\n\ The optional protocol name, if given, should be 'tcp' or 'udp',\n\ otherwise any protocol will match.") | |
| PyDoc_STRVAR (getservbyname_doc,"getservbyname(servicename[, protocolname]) -> integer\n\ \n\ Return a port number from a service name and protocol name.\n\ The optional protocol name, if given, should be 'tcp' or 'udp',\n\ otherwise any protocol will match.") | |
| PyDoc_STRVAR (gethostbyaddr_doc,"gethostbyaddr(host) -> (name, aliaslist, addresslist)\n\ \n\ Return the true host name, a list of aliases, and a list of IP addresses,\n\ for a host. The host argument is a string giving a host name or IP number.") | |
| PyDoc_STRVAR (ghbn_ex_doc,"gethostbyname_ex(host) -> (name, aliaslist, addresslist)\n\ \n\ Return the true host name, a list of aliases, and a list of IP addresses,\n\ for a host. The host argument is a string giving a host name or IP number.") | |
| PyDoc_STRVAR (gethostbyname_doc,"gethostbyname(host) -> address\n\ \n\ Return the IP address (a string of the form '255.255.255.255') for a host.") | |
| PyDoc_STRVAR (gethostname_doc,"gethostname() -> string\n\ \n\ Return the current host name.") | |
| PyDoc_STRVAR (shutdown_doc,"shutdown(flag)\n\ \n\ Shut down the reading side of the socket (flag == SHUT_RD), the writing side\n\ of the socket (flag == SHUT_WR), or both ends (flag == SHUT_RDWR).") | |
| PyDoc_STRVAR (sendto_doc,"sendto(data[, flags], address) -> count\n\ \n\ Like send(data, flags) but allows specifying the destination address.\n\ For IP sockets, the address is a pair (hostaddr, port).") | |
| PyDoc_STRVAR (sendall_doc,"sendall(data[, flags])\n\ \n\ Send a data string to the socket. For the optional flags\n\ argument, see the Unix manual. This calls send() repeatedly\n\ until all data is sent. If an error occurs, it's impossible\n\ to tell how much data has been sent.") | |
| PyDoc_STRVAR (send_doc,"send(data[, flags]) -> count\n\ \n\ Send a data string to the socket. For the optional flags\n\ argument, see the Unix manual. Return the number of bytes\n\ sent; this may be less than len(data) if the network is busy.") | |
| PyDoc_STRVAR (recvfrom_into_doc,"recvfrom_into(buffer[, nbytes[, flags]]) -> (nbytes, address info)\n\ \n\ Like recv_into(buffer[, nbytes[, flags]]) but also return the sender's address info.") | |
| PyDoc_STRVAR (recvfrom_doc,"recvfrom(buffersize[, flags]) -> (data, address info)\n\ \n\ Like recv(buffersize, flags) but also return the sender's address info.") | |
| PyDoc_STRVAR (recv_into_doc,"recv_into(buffer, [nbytes[, flags]]) -> nbytes_read\n\ \n\ A version of recv() that stores its data into a buffer rather than creating \n\ a new string. Receive up to buffersize bytes from the socket. If buffersize \n\ is not specified (or 0), receive up to the size available in the given buffer.\n\ \n\ See recv() for documentation about the flags.") | |
| PyDoc_STRVAR (recv_doc,"recv(buffersize[, flags]) -> data\n\ \n\ Receive up to buffersize bytes from the socket. For the optional flags\n\ argument, see the Unix manual. When no data is available, block until\n\ at least one byte is available or until the remote end is closed. When\n\ the remote end is closed and all data is read, return the empty string.") | |
| PyDoc_STRVAR (makefile_doc,"makefile([mode[, buffersize]]) -> file object\n\ \n\ Return a regular file object corresponding to the socket.\n\ The mode and buffersize arguments are as for the built-in open() function.") | |
| PyDoc_STRVAR (listen_doc,"listen(backlog)\n\ \n\ Enable a server to accept connections. The backlog argument must be at\n\ least 1; it specifies the number of unaccepted connection that the system\n\ will allow before refusing new connections.") | |
| PyDoc_STRVAR (getsockname_doc,"getsockname() -> address info\n\ \n\ Return the address of the local endpoint. For IP sockets, the address\n\ info is a pair (hostaddr, port).") | |
| PyDoc_STRVAR (dup_doc,"dup() -> socket object\n\ \n\ Return a new socket object connected to the same system resource.") | |
| PyDoc_STRVAR (fileno_doc,"fileno() -> integer\n\ \n\ Return the integer file descriptor of the socket.") | |
| PyDoc_STRVAR (connect_ex_doc,"connect_ex(address) -> errno\n\ \n\ This is like connect(address), but returns an error code (the errno value)\n\ instead of raising an exception when an error occurs.") | |
| PyDoc_STRVAR (connect_doc,"connect(address)\n\ \n\ Connect the socket to a remote address. For IP sockets, the address\n\ is a pair (host, port).") | |
| PyDoc_STRVAR (close_doc,"close()\n\ \n\ Close the socket. It cannot be used after this call.") | |
| PyDoc_STRVAR (bind_doc,"bind(address)\n\ \n\ Bind the socket to a local address. For IP sockets, the address is a\n\ pair (host, port); the host must refer to the local host. For raw packet\n\ sockets the address is a tuple (ifname, proto [,pkttype [,hatype]])") | |
| PyDoc_STRVAR (getsockopt_doc,"getsockopt(level, option[, buffersize]) -> value\n\ \n\ Get a socket option. See the Unix manual for level and option.\n\ If a nonzero buffersize argument is given, the return value is a\n\ string of that length; otherwise it is an integer.") | |
| PyDoc_STRVAR (setsockopt_doc,"setsockopt(level, option, value)\n\ \n\ Set a socket option. See the Unix manual for level and option.\n\ The value argument can either be an integer or a string.") | |
| PyDoc_STRVAR (gettimeout_doc,"gettimeout() -> timeout\n\ \n\ Returns the timeout in floating seconds associated with socket \n\ operations. A timeout of None indicates that timeouts on socket \n\ operations are disabled.") | |
| PyDoc_STRVAR (settimeout_doc,"settimeout(timeout)\n\ \n\ Set a timeout on socket operations. 'timeout' can be a float,\n\ giving in seconds, or None. Setting a timeout of None disables\n\ the timeout feature and is equivalent to setblocking(1).\n\ Setting a timeout of zero is the same as setblocking(0).") | |
| PyDoc_STRVAR (setblocking_doc,"setblocking(flag)\n\ \n\ Set the socket to blocking (flag is true) or non-blocking (false).\n\ setblocking(True) is equivalent to settimeout(None);\n\ setblocking(False) is equivalent to settimeout(0.0).") | |
| PyDoc_STRVAR (accept_doc,"accept() -> (socket object, address info)\n\ \n\ Wait for an incoming connection. Return a new socket representing the\n\ connection, and the address of the client. For IP sockets, the address\n\ info is a pair (hostaddr, port).") | |
| PyDoc_STRVAR (sock_doc,"socket([family[, type[, proto]]]) -> socket object\n\ \n\ Open a socket of the given type. The family argument specifies the\n\ address family; it defaults to AF_INET. The type argument specifies\n\ whether this is a stream (SOCK_STREAM, this is the default)\n\ or datagram (SOCK_DGRAM) socket. The protocol argument defaults to 0,\n\ specifying the default protocol. Keyword arguments are accepted.\n\ \n\ A socket object represents one endpoint of a network connection.\n\ \n\ Methods of socket objects (keyword arguments not allowed):\n\ \n\ accept() -- accept a connection, returning new socket and client address\n\ bind(addr) -- bind the socket to a local address\n\ close() -- close the socket\n\ connect(addr) -- connect the socket to a remote address\n\ connect_ex(addr) -- connect, return an error code instead of an exception\n\ dup() -- return a new socket object identical to the current one [*]\n\ fileno() -- return underlying file descriptor\n\ getpeername() -- return remote address [*]\n\ getsockname() -- return local address\n\ getsockopt(level, optname[, buflen]) -- get socket options\n\ gettimeout() -- return timeout or None\n\ listen(n) -- start listening for incoming connections\n\ makefile([mode, [bufsize]]) -- return a file object for the socket [*]\n\ recv(buflen[, flags]) -- receive data\n\ recv_into(buffer[, nbytes[, flags]]) -- receive data (into a buffer)\n\ recvfrom(buflen[, flags]) -- receive data and sender\'s address\n\ recvfrom_into(buffer[, nbytes, [, flags])\n\ -- receive data and sender\'s address (into a buffer)\n\ sendall(data[, flags]) -- send all data\n\ send(data[, flags]) -- send data, may not send all of it\n\ sendto(data[, flags], addr) -- send data to a given address\n\ setblocking(0 | 1) -- set or clear the blocking I/O flag\n\ setsockopt(level, optname, value) -- set socket options\n\ settimeout(None | float) -- set or clear the timeout\n\ shutdown(how) -- shut down traffic in one or both directions\n\ \n\ [*] not available on all platforms!") | |
| static PyObject * | select_error (void) |
| static PyObject * | set_error (void) |
| static PyObject * | set_gaierror (int error) |
| static PyObject * | set_herror (int h_error) |
| static int | setipaddr (char *name, struct sockaddr *addr_ret, size_t addr_ret_size, int af) |
| static PyObject * | sock_accept (PySocketSockObject *s) |
| static PyObject * | sock_bind (PySocketSockObject *s, PyObject *addro) |
| static PyObject * | sock_close (PySocketSockObject *s) |
| static PyObject * | sock_connect (PySocketSockObject *s, PyObject *addro) |
| static PyObject * | sock_connect_ex (PySocketSockObject *s, PyObject *addro) |
| static void | sock_dealloc (PySocketSockObject *s) |
| static PyObject * | sock_dup (PySocketSockObject *s) |
| static PyObject * | sock_fileno (PySocketSockObject *s) |
| static PyObject * | sock_getsockname (PySocketSockObject *s) |
| static PyObject * | sock_getsockopt (PySocketSockObject *s, PyObject *args) |
| static PyObject * | sock_gettimeout (PySocketSockObject *s) |
| static int | sock_initobj (PyObject *self, PyObject *args, PyObject *kwds) |
| static PyObject * | sock_listen (PySocketSockObject *s, PyObject *arg) |
| static PyObject * | sock_makefile (PySocketSockObject *s, PyObject *args) |
| static PyObject * | sock_new (PyTypeObject *type, PyObject *args, PyObject *kwds) |
| static PyObject * | sock_recv (PySocketSockObject *s, PyObject *args) |
| static ssize_t | sock_recv_guts (PySocketSockObject *s, char *cbuf, int len, int flags) |
| static PyObject * | sock_recv_into (PySocketSockObject *s, PyObject *args, PyObject *kwds) |
| static PyObject * | sock_recvfrom (PySocketSockObject *s, PyObject *args) |
| static ssize_t | sock_recvfrom_guts (PySocketSockObject *s, char *cbuf, int len, int flags, PyObject **addr) |
| static PyObject * | sock_recvfrom_into (PySocketSockObject *s, PyObject *args, PyObject *kwds) |
| static PyObject * | sock_repr (PySocketSockObject *s) |
| static PyObject * | sock_send (PySocketSockObject *s, PyObject *args) |
| static PyObject * | sock_sendall (PySocketSockObject *s, PyObject *args) |
| static PyObject * | sock_sendto (PySocketSockObject *s, PyObject *args) |
| static PyObject * | sock_setblocking (PySocketSockObject *s, PyObject *arg) |
| static PyObject * | sock_setsockopt (PySocketSockObject *s, PyObject *args) |
| static PyObject * | sock_settimeout (PySocketSockObject *s, PyObject *arg) |
| static PyObject * | sock_shutdown (PySocketSockObject *s, PyObject *arg) |
| static PyObject * | socket_fromfd (PyObject *self, PyObject *args) |
| static PyObject * | socket_getaddrinfo (PyObject *self, PyObject *args) |
| static PyObject * | socket_getdefaulttimeout (PyObject *self) |
| static PyObject * | socket_gethostbyaddr (PyObject *self, PyObject *args) |
| static PyObject * | socket_gethostbyname (PyObject *self, PyObject *args) |
| static PyObject * | socket_gethostbyname_ex (PyObject *self, PyObject *args) |
| static PyObject * | socket_gethostname (PyObject *self, PyObject *unused) |
| static PyObject * | socket_getnameinfo (PyObject *self, PyObject *args) |
| static PyObject * | socket_getprotobyname (PyObject *self, PyObject *args) |
| static PyObject * | socket_getservbyname (PyObject *self, PyObject *args) |
| static PyObject * | socket_getservbyport (PyObject *self, PyObject *args) |
| static PyObject * | socket_htonl (PyObject *self, PyObject *arg) |
| static PyObject * | socket_htons (PyObject *self, PyObject *args) |
| static PyObject * | socket_inet_aton (PyObject *self, PyObject *args) |
| static PyObject * | socket_inet_ntoa (PyObject *self, PyObject *args) |
| static PyObject * | socket_ntohl (PyObject *self, PyObject *arg) |
| static PyObject * | socket_ntohs (PyObject *self, PyObject *args) |
| static PyObject * | socket_setdefaulttimeout (PyObject *self, PyObject *arg) |
Variables | |
| static double | defaulttimeout = -1.0 |
| static PySocketModule_APIObject | PySocketModuleAPI |
| static PyMemberDef | sock_memberlist [] |
| static PyMethodDef | sock_methods [] |
| static PyTypeObject | sock_type |
| static PyObject * | socket_error |
| static PyObject * | socket_gaierror |
| static PyObject * | socket_herror |
| static PyMethodDef | socket_methods [] |
| static PyObject * | socket_timeout |
| #define ACQUIRE_GETADDRINFO_LOCK |
Referenced by setipaddr(), socket_getaddrinfo(), and socket_getnameinfo().
| #define cppstring | ( | x | ) | #x |
| #define freeaddrinfo fake_freeaddrinfo |
Referenced by setipaddr(), socket_getaddrinfo(), and socket_getnameinfo().
| #define gai_strerror fake_gai_strerror |
Referenced by set_gaierror().
| #define getaddrinfo fake_getaddrinfo |
Referenced by setipaddr(), socket_getaddrinfo(), and socket_getnameinfo().
| #define getnameinfo fake_getnameinfo |
Referenced by makeipaddr(), and socket_getnameinfo().
| #define INADDR_NONE (-1) |
Referenced by inet_pton(), init_socket(), and socket_inet_aton().
| #define IS_SELECTABLE | ( | s | ) | ((s)->sock_fd < FD_SETSIZE || s->sock_timeout <= 0.0) |
Referenced by internal_connect(), sock_accept(), sock_recv_guts(), sock_recvfrom_guts(), sock_send(), sock_sendall(), and sock_sendto().
| #define MAX | ( | x, | |||
| y | ) | ((x) < (y) ? (y) : (x)) |
Referenced by vtkImageGCR::mnbrak().
| #define NI_MAXHOST 1025 |
Referenced by init_socket(), makeipaddr(), and socket_getnameinfo().
| #define NI_MAXSERV 32 |
Referenced by init_socket(), and socket_getnameinfo().
| #define O_NONBLOCK O_NDELAY |
Referenced by internal_setblocking(), and vtkUDPServerLogic::StartServerConnection().
| #define PySocket_BUILDING_SOCKET |
| #define RELEASE_GETADDRINFO_LOCK |
Referenced by setipaddr(), socket_getaddrinfo(), and socket_getnameinfo().
| #define SAS2SA | ( | x | ) | ((struct sockaddr *)(x)) |
Referenced by sock_accept(), sock_bind(), sock_connect(), sock_connect_ex(), sock_getsockname(), sock_recvfrom_guts(), sock_sendto(), and socket_gethostbyname().
| #define SOCKETCLOSE close |
Referenced by sock_accept(), sock_close(), sock_dealloc(), sock_dup(), and sock_makefile().
| static PyObject* gethost_common | ( | struct hostent * | h, | |
| struct sockaddr * | addr, | |||
| int | alen, | |||
| int | af | |||
| ) | [static] |
References makeipaddr(), set_herror(), and socket_error.
Referenced by socket_gethostbyaddr(), and socket_gethostbyname_ex().
| static int getsockaddrarg | ( | PySocketSockObject * | s, | |
| PyObject * | args, | |||
| struct sockaddr * | addr_ret, | |||
| int * | len_ret | |||
| ) | [static] |
References slicerget::host, birnlexvis::port, result, setipaddr(), and socket_error.
Referenced by sock_bind(), sock_connect(), sock_connect_ex(), and sock_sendto().
| static int getsockaddrlen | ( | PySocketSockObject * | s, | |
| socklen_t * | len_ret | |||
| ) | [static] |
References socket_error.
Referenced by sock_accept(), sock_getsockname(), and sock_recvfrom_guts().
References INADDR_NONE.
| PyMODINIT_FUNC init_socket | ( | void | ) |
References INADDR_NONE, NI_MAXHOST, NI_MAXSERV, os_init(), socket_error, socket_gaierror, socket_herror, and socket_timeout.
| PyMODINIT_FUNC init_sockobject | ( | PySocketSockObject * | s, | |
| SOCKET_T | fd, | |||
| int | family, | |||
| int | type, | |||
| int | proto | |||
| ) |
References internal_setblocking(), and set_error().
Referenced by new_sockobject(), and sock_initobj().
| static int internal_connect | ( | PySocketSockObject * | s, | |
| struct sockaddr * | addr, | |||
| int | addrlen, | |||
| int * | timeoutp | |||
| ) | [static] |
References connect(), internal_select(), and IS_SELECTABLE.
Referenced by sock_connect(), and sock_connect_ex().
Referenced by internal_connect(), sock_accept(), sock_recv_guts(), sock_recvfrom_guts(), sock_send(), sock_sendall(), and sock_sendto().
References O_NONBLOCK.
Referenced by init_sockobject(), sock_setblocking(), and sock_settimeout().
| static PyObject* makeipaddr | ( | struct sockaddr * | addr, | |
| int | addrlen | |||
| ) | [static] |
References error(), getnameinfo, NI_MAXHOST, and set_gaierror().
Referenced by gethost_common(), makesockaddr(), and socket_gethostbyname().
| static PyObject* makesockaddr | ( | int | sockfd, | |
| struct sockaddr * | addr, | |||
| int | addrlen, | |||
| int | proto | |||
| ) | [static] |
References makeipaddr(), and autoSlicerTracto2regions::ret.
Referenced by sock_accept(), sock_getsockname(), sock_recvfrom_guts(), and socket_getaddrinfo().
References init_sockobject(), ipTk::s, and sock_type.
Referenced by sock_accept(), sock_dup(), and socket_fromfd().
| static int os_init | ( | void | ) | [static] |
Referenced by init_socket().
| PyDoc_STRVAR | ( | socket_doc | , | |
| "Implementation module for socket operations.\n\\n\See the socket module for documentation." | ||||
| ) |
| PyDoc_STRVAR | ( | setdefaulttimeout_doc | , | |
| "setdefaulttimeout(timeout)\n\\n\Set the default timeout in floating seconds for new socket objects.\n\A value of None indicates that new socket objects have no timeout.\n\When the socket module is first | imported, | |||
| the default is None." | ||||
| ) |
| PyDoc_STRVAR | ( | getdefaulttimeout_doc | , | |
| "getdefaulttimeout() -> timeout\n\\n\Returns the default timeout in floating seconds for new socket objects.\n\A value of None indicates that new socket objects have no timeout.\n\When the socket module is first | imported, | |||
| the default is None." | ||||
| ) |
| PyDoc_STRVAR | ( | getnameinfo_doc | , | |
| "getnameinfo(sockaddr, flags) --> (host, port)\n\\n\Get host and port for a sockaddr." | ||||
| ) |
| PyDoc_STRVAR | ( | getaddrinfo_doc | , | |
| "getaddrinfo(host, port [, family, socktype, proto, flags])\n\ -> list of (family, socktype, proto, canonname, sockaddr)\n\\n\Resolve host and port into addrinfo struct." | ||||
| ) |
| PyDoc_STRVAR | ( | inet_ntoa_doc | , | |
| "inet_ntoa(packed_ip) -> ip_address_string\n\\n\Convert an IP address from 32-bit packed binary format to string format" | ||||
| ) |
| PyDoc_STRVAR | ( | inet_aton_doc | , | |
| "inet_aton(string) -> packed 32-bit IP representation\n\\n\Convert an IP address in string format (123.45.67.89) to the 32-bit packed\n\binary format used in low-level network functions." | ||||
| ) |
| PyDoc_STRVAR | ( | htonl_doc | , | |
| "htonl(integer) -> integer\n\\n\Convert a 32-bit integer from host to network byte order." | ||||
| ) |
| PyDoc_STRVAR | ( | htons_doc | , | |
| "htons(integer) -> integer\n\\n\Convert a 16-bit integer from host to network byte order." | ||||
| ) |
| PyDoc_STRVAR | ( | ntohl_doc | , | |
| "ntohl(integer) -> integer\n\\n\Convert a 32-bit integer from network to host byte order." | ||||
| ) |
| PyDoc_STRVAR | ( | ntohs_doc | , | |
| "ntohs(integer) -> integer\n\\n\Convert a 16-bit integer from network to host byte order." | ||||
| ) |
| PyDoc_STRVAR | ( | fromfd_doc | , | |
| "fromfd(fd, family, type[, proto]) -> socket object\n\\n\Create a socket object from a duplicate of the given\n\file descriptor.\n\The remaining arguments are the same as for socket()." | ||||
| ) |
| PyDoc_STRVAR | ( | getprotobyname_doc | , | |
| "getprotobyname(name) -> integer\n\\n\Return the protocol number for the named protocol. (Rarely used.)" | ||||
| ) |
| PyDoc_STRVAR | ( | getservbyport_doc | , | |
| "getservbyport(port[, protocolname]) -> string\n\\n\Return the service name from a port number and protocol name.\n\The optional protocol | name, | |||
| if | given, | |||
| should be 'tcp'or 'udp' | , | |||
| \n\otherwise any protocol will match." | ||||
| ) |
| PyDoc_STRVAR | ( | getservbyname_doc | , | |
| "getservbyname(servicename[, protocolname]) -> integer\n\\n\Return a port number from a service name and protocol name.\n\The optional protocol | name, | |||
| if | given, | |||
| should be 'tcp'or 'udp' | , | |||
| \n\otherwise any protocol will match." | ||||
| ) |
| PyDoc_STRVAR | ( | gethostbyaddr_doc | , | |
| "gethostbyaddr(host) -> (name, aliaslist, addresslist)\n\\n\Return the true host | name, | |||
| a list of | aliases, | |||
| and a list of IP | addresses, | |||
| \n\for a host.The host argument is a string giving a host name or IP number." | ||||
| ) |
| PyDoc_STRVAR | ( | ghbn_ex_doc | , | |
| "gethostbyname_ex(host) -> (name, aliaslist, addresslist)\n\\n\Return the true host | name, | |||
| a list of | aliases, | |||
| and a list of IP | addresses, | |||
| \n\for a host.The host argument is a string giving a host name or IP number." | ||||
| ) |
| PyDoc_STRVAR | ( | gethostbyname_doc | , | |
| "gethostbyname(host) -> address\n\\n\Return the IP address (a string of the form '255.255.255.255') for a host." | ||||
| ) |
| PyDoc_STRVAR | ( | gethostname_doc | , | |
| "gethostname() -> string\n\\n\Return the current host name." | ||||
| ) |
| PyDoc_STRVAR | ( | shutdown_doc | , | |
| " | shutdownflag)\n\\n\Shut down the reading side of the socket (flag == SHUT_RD, | |||
| the writing side\n\of the | socketflag==SHUT_WR, | |||
| or both ends(flag==SHUT_RDWR)." | ||||
| ) |
| PyDoc_STRVAR | ( | sendto_doc | , | |
| "sendto(data[, flags], address) -> count\n\\n\Like send(data, flags) but allows specifying the destination address.\n\For IP | sockets, | |||
| the address is a pair(hostaddr, port)." | ||||
| ) |
| PyDoc_STRVAR | ( | sendall_doc | , | |
| "sendall(data[, flags])\n\\n\Send a data string to the socket. For the optional flags\n\ | argument, | |||
| see the Unix manual.This calls send() repeatedly\n\until all data is sent.If an error | occurs, | |||
| it's impossible\n\to tell how much data has been sent." | ||||
| ) |
| PyDoc_STRVAR | ( | send_doc | , | |
| "send(data[, flags]) -> count\n\\n\Send a data string to the socket. For the optional flags\n\ | argument, | |||
| see the Unix manual.Return the number of bytes\n\sent;this may be less than len(data) if the network is busy." | ||||
| ) |
| PyDoc_STRVAR | ( | recvfrom_into_doc | , | |
| "recvfrom_into(buffer[, nbytes[, flags]]) -> (nbytes, address info)\n\\n\Like recv_into(buffer[, nbytes[, flags]]) but also return the sender's address info." | ||||
| ) |
| PyDoc_STRVAR | ( | recvfrom_doc | , | |
| "recvfrom(buffersize[, flags]) -> (data, address info)\n\\n\Like recv(buffersize, flags) but also return the sender's address info." | ||||
| ) |
| PyDoc_STRVAR | ( | recv_into_doc | , | |
| " | recv_intobuffer, [nbytes[, flags]]) -> nbytes_read\n\\n\A version of recv() that stores its data into a buffer rather than creating \n\a new string. Receive up to buffersize bytes from the socket. If buffersize \n\is not specified (or 0, | |||
| receive up to the size available in the given buffer.\n\\n\See recv() for documentation about the flags." | ||||
| ) |
| PyDoc_STRVAR | ( | recv_doc | , | |
| "recv(buffersize[, flags]) -> data\n\\n\Receive up to buffersize bytes from the socket. For the optional flags\n\ | argument, | |||
| see the Unix manual.When no data is | available, | |||
| block until\n\at least one byte is available or until the remote end is closed.When\n\the remote end is closed and all data is | read, | |||
| return the empty string." | ||||
| ) |
| PyDoc_STRVAR | ( | makefile_doc | , | |
| "makefile([mode[, buffersize]]) -> file object\n\\n\Return a regular file object corresponding to the socket.\n\The mode and buffersize arguments are as for the built-in open() function." | ||||
| ) |
| PyDoc_STRVAR | ( | listen_doc | , | |
| "listen(backlog)\n\\n\Enable a server to accept connections. The backlog argument must be at\n\least 1; it specifies the number of unaccepted connection that the system\n\will allow before refusing new connections." | ||||
| ) |
| PyDoc_STRVAR | ( | getsockname_doc | , | |
| "getsockname() -> address info\n\\n\Return the address of the local endpoint. For IP | sockets, | |||
| the address\n\info is a pair(hostaddr, port)." | ||||
| ) |
| PyDoc_STRVAR | ( | dup_doc | , | |
| "dup() -> socket object\n\\n\Return a new socket object connected to the same system resource." | ||||
| ) |
| PyDoc_STRVAR | ( | fileno_doc | , | |
| "fileno() -> integer\n\\n\Return the integer file descriptor of the socket." | ||||
| ) |
| PyDoc_STRVAR | ( | connect_ex_doc | , | |
| " | connect_exaddress) -> errno\n\\n\This is like connect(address, | |||
| but returns an error code(the errno value)\n\instead of raising an exception when an error occurs." | ||||
| ) |
| PyDoc_STRVAR | ( | connect_doc | , | |
| "connect(address)\n\\n\Connect the socket to a remote address. For IP | sockets, | |||
| the address\n\is a pair(host, port)." | ||||
| ) |
| PyDoc_STRVAR | ( | close_doc | , | |
| "close()\n\\n\Close the socket. It cannot be used after this call." | ||||
| ) |
| PyDoc_STRVAR | ( | bind_doc | , | |
| "bind(address)\n\\n\Bind the socket to a local address. For IP | sockets, | |||
| the address is a\n\pair(host, port);the host must refer to the local host.For raw packet\n\sockets the address is a tuple(ifname, proto[, pkttype[, hatype]])" | ||||
| ) |
| PyDoc_STRVAR | ( | getsockopt_doc | , | |
| "getsockopt(level, option[, buffersize]) -> value\n\\n\Get a socket option. See the Unix manual for level and option.\n\If a nonzero buffersize argument is | given, | |||
| the return value is a\n\string of that length;otherwise it is an integer." | ||||
| ) |
| PyDoc_STRVAR | ( | setsockopt_doc | , | |
| "setsockopt(level, option, value)\n\\n\Set a socket option. See the Unix manual for level and option.\n\The value argument can either be an integer or a string." | ||||
| ) |
| PyDoc_STRVAR | ( | gettimeout_doc | , | |
| "gettimeout() -> timeout\n\\n\Returns the timeout in floating seconds associated with socket \n\operations. A timeout of None indicates that timeouts on socket \n\operations are disabled." | ||||
| ) |
| PyDoc_STRVAR | ( | settimeout_doc | , | |
| "settimeout(timeout)\n\\n\Set a timeout on socket operations. 'timeout' can be a | float, | |||
| \n\giving in | seconds, | |||
| or None.Setting a timeout of None disables\n\the timeout feature and is equivalent to setblocking(1).\n\Setting a timeout of zero is the same as setblocking(0)." | ||||
| ) |
| PyDoc_STRVAR | ( | setblocking_doc | , | |
| "setblocking(flag)\n\\n\Set the socket to blocking (flag is true) or non-blocking (false).\n\setblocking(True) is equivalent to settimeout(None);\n\setblocking(False) is equivalent to settimeout(0.0)." | ||||
| ) |
| PyDoc_STRVAR | ( | accept_doc | , | |
| "accept() -> (socket object, address info)\n\\n\Wait for an incoming connection. Return a new socket representing the\n\ | connection, | |||
| and the address of the client.For IP | sockets, | |||
| the address\n\info is a pair(hostaddr, port)." | ||||
| ) |
| PyDoc_STRVAR | ( | sock_doc | , | |
| "socket([family[, type[, proto]]]) -> socket object\n\\n\Open a socket of the given type. The family argument specifies the\n\address family; it defaults to AF_INET. The type argument specifies\n\whether this is a stream (SOCK_STREAM, this is the default)\n\or datagram (SOCK_DGRAM) socket. The protocol argument defaults to | 0, | |||
| \n\specifying the default protocol.Keyword arguments are accepted.\n\\n\A socket object represents one endpoint of a network connection.\n\\n\Methods of socket objects(keyword arguments not allowed):\n\\n\accept()--accept a | connection, | |||
| returning new socket and client address\n\bind(addr)--bind the socket to a local address\n\close()--close the socket\n\connect(addr)--connect the socket to a remote address\n\connect_ex(addr)-- | connect, | |||
| return an error code instead of an exception\n\dup()--return a new socket object identical to the current one\n\fileno()--return underlying file descriptor\n\getpeername()--return remote address\n\getsockname()--return local address\n\getsockopt(level, optname[, buflen])--get socket options\n\gettimeout()--return timeout or None\n\listen(n)--start listening for incoming connections\n\makefile([mode,[bufsize]])--return a file object for the socket\n\recv(buflen[, flags])--receive data\n\recv_into(buffer[, nbytes[, flags]])--receive data(into a buffer)\n\recvfrom(buflen[, flags])--receive data and sender\'s address\n\recvfrom_into(buffer[, nbytes,[, flags])\n\--receive data and sender\'s address(into a buffer)\n\sendall(data[, flags])--send all data\n\send(data[, flags])--send | data[*][*][*], | |||
| may not send all of it\n\sendto(data[, flags], addr)--send data to a given address\n\setblocking(0|1)--set or clear the blocking I/O flag\n\setsockopt(level, optname, value)--set socket options\n\settimeout(None|float)--set or clear the timeout\n\shutdown(how)--shut down traffic in one or both directions\n\\n\not available on all platforms!" | [*] | |||
| ) |
Referenced by sock_getsockopt().
| static PyObject* select_error | ( | void | ) | [static] |
References socket_error.
Referenced by sock_accept(), sock_recv_guts(), sock_recvfrom_guts(), sock_send(), sock_sendall(), and sock_sendto().
| static PyObject* set_error | ( | void | ) | [static] |
References socket_error.
Referenced by init_sockobject(), set_gaierror(), sock_initobj(), sock_new(), socket_fromfd(), and socket_gethostname().
| static PyObject* set_gaierror | ( | int | error | ) | [static] |
References gai_strerror, set_error(), and socket_gaierror.
Referenced by makeipaddr(), setipaddr(), socket_getaddrinfo(), and socket_getnameinfo().
| static PyObject* set_herror | ( | int | h_error | ) | [static] |
References socket_herror.
Referenced by gethost_common().
| static int setipaddr | ( | char * | name, | |
| struct sockaddr * | addr_ret, | |||
| size_t | addr_ret_size, | |||
| int | af | |||
| ) | [static] |
References ACQUIRE_GETADDRINFO_LOCK, error(), freeaddrinfo, getaddrinfo, RELEASE_GETADDRINFO_LOCK, set_gaierror(), and socket_error.
Referenced by getsockaddrarg(), socket_gethostbyaddr(), socket_gethostbyname(), and socket_gethostbyname_ex().
| static PyObject* sock_accept | ( | PySocketSockObject * | s | ) | [static] |
References getsockaddrlen(), internal_select(), IS_SELECTABLE, makesockaddr(), new_sockobject(), SAS2SA, select_error(), socket_timeout, and SOCKETCLOSE.
| static PyObject* sock_bind | ( | PySocketSockObject * | s, | |
| PyObject * | addro | |||
| ) | [static] |
References getsockaddrarg(), and SAS2SA.
| static PyObject* sock_close | ( | PySocketSockObject * | s | ) | [static] |
References SOCKETCLOSE.
| static PyObject* sock_connect | ( | PySocketSockObject * | s, | |
| PyObject * | addro | |||
| ) | [static] |
References getsockaddrarg(), internal_connect(), SAS2SA, and socket_timeout.
| static PyObject* sock_connect_ex | ( | PySocketSockObject * | s, | |
| PyObject * | addro | |||
| ) | [static] |
References getsockaddrarg(), internal_connect(), and SAS2SA.
| static void sock_dealloc | ( | PySocketSockObject * | s | ) | [static] |
References SOCKETCLOSE.
| static PyObject* sock_dup | ( | PySocketSockObject * | s | ) | [static] |
References new_sockobject(), and SOCKETCLOSE.
| static PyObject* sock_fileno | ( | PySocketSockObject * | s | ) | [static] |
| static PyObject* sock_getsockname | ( | PySocketSockObject * | s | ) | [static] |
References getsockaddrlen(), makesockaddr(), and SAS2SA.
| static PyObject* sock_getsockopt | ( | PySocketSockObject * | s, | |
| PyObject * | args | |||
| ) | [static] |
References PyDoc_STRVAR(), and socket_error.
| static PyObject* sock_gettimeout | ( | PySocketSockObject * | s | ) | [static] |
| static int sock_initobj | ( | PyObject * | self, | |
| PyObject * | args, | |||
| PyObject * | kwds | |||
| ) | [static] |
References init_sockobject(), set_error(), and type.
| static PyObject* sock_listen | ( | PySocketSockObject * | s, | |
| PyObject * | arg | |||
| ) | [static] |
| static PyObject* sock_makefile | ( | PySocketSockObject * | s, | |
| PyObject * | args | |||
| ) | [static] |
References fclose, FILE, slicerget::fp, and SOCKETCLOSE.
| static PyObject* sock_new | ( | PyTypeObject * | type, | |
| PyObject * | args, | |||
| PyObject * | kwds | |||
| ) | [static] |
References set_error().
| static PyObject* sock_recv | ( | PySocketSockObject * | s, | |
| PyObject * | args | |||
| ) | [static] |
References sock_recv_guts().
References internal_select(), IS_SELECTABLE, select_error(), and socket_timeout.
Referenced by sock_recv(), and sock_recv_into().
| static PyObject* sock_recv_into | ( | PySocketSockObject * | s, | |
| PyObject * | args, | |||
| PyObject * | kwds | |||
| ) | [static] |
References sock_recv_guts().
| static PyObject* sock_recvfrom | ( | PySocketSockObject * | s, | |
| PyObject * | args | |||
| ) | [static] |
References autoSlicerTracto2regions::ret, and sock_recvfrom_guts().
| static ssize_t sock_recvfrom_guts | ( | PySocketSockObject * | s, | |
| char * | cbuf, | |||
| int | len, | |||
| int | flags, | |||
| PyObject ** | addr | |||
| ) | [static] |
References getsockaddrlen(), internal_select(), IS_SELECTABLE, makesockaddr(), SAS2SA, select_error(), and socket_timeout.
Referenced by sock_recvfrom(), and sock_recvfrom_into().
| static PyObject* sock_recvfrom_into | ( | PySocketSockObject * | s, | |
| PyObject * | args, | |||
| PyObject * | kwds | |||
| ) | [static] |
References sock_recvfrom_guts().
| static PyObject* sock_repr | ( | PySocketSockObject * | s | ) | [static] |
| static PyObject* sock_send | ( | PySocketSockObject * | s, | |
| PyObject * | args | |||
| ) | [static] |
References internal_select(), IS_SELECTABLE, select_error(), and socket_timeout.
| static PyObject* sock_sendall | ( | PySocketSockObject * | s, | |
| PyObject * | args | |||
| ) | [static] |
References internal_select(), IS_SELECTABLE, select_error(), and socket_timeout.
| static PyObject* sock_sendto | ( | PySocketSockObject * | s, | |
| PyObject * | args | |||
| ) | [static] |
References getsockaddrarg(), internal_select(), IS_SELECTABLE, SAS2SA, select_error(), and socket_timeout.
| static PyObject* sock_setblocking | ( | PySocketSockObject * | s, | |
| PyObject * | arg | |||
| ) | [static] |
References internal_setblocking().
| static PyObject* sock_setsockopt | ( | PySocketSockObject * | s, | |
| PyObject * | args | |||
| ) | [static] |
| static PyObject* sock_settimeout | ( | PySocketSockObject * | s, | |
| PyObject * | arg | |||
| ) | [static] |
References internal_setblocking().
| static PyObject* sock_shutdown | ( | PySocketSockObject * | s, | |
| PyObject * | arg | |||
| ) | [static] |
| static PyObject* socket_fromfd | ( | PyObject * | self, | |
| PyObject * | args | |||
| ) | [static] |
References new_sockobject(), and set_error().
| static PyObject* socket_getaddrinfo | ( | PyObject * | self, | |
| PyObject * | args | |||
| ) | [static] |
References ACQUIRE_GETADDRINFO_LOCK, error(), freeaddrinfo, getaddrinfo, makesockaddr(), RELEASE_GETADDRINFO_LOCK, set_gaierror(), and socket_error.
| static PyObject* socket_getdefaulttimeout | ( | PyObject * | self | ) | [static] |
| static PyObject* socket_gethostbyaddr | ( | PyObject * | self, | |
| PyObject * | args | |||
| ) | [static] |
References gethost_common(), result, autoSlicerTracto2regions::ret, setipaddr(), and socket_error.
| static PyObject* socket_gethostbyname | ( | PyObject * | self, | |
| PyObject * | args | |||
| ) | [static] |
References makeipaddr(), SAS2SA, and setipaddr().
| static PyObject* socket_gethostbyname_ex | ( | PyObject * | self, | |
| PyObject * | args | |||
| ) | [static] |
References gethost_common(), result, autoSlicerTracto2regions::ret, and setipaddr().
| static PyObject* socket_gethostname | ( | PyObject * | self, | |
| PyObject * | unused | |||
| ) | [static] |
References set_error().
| static PyObject* socket_getnameinfo | ( | PyObject * | self, | |
| PyObject * | args | |||
| ) | [static] |
| static PyObject* socket_getprotobyname | ( | PyObject * | self, | |
| PyObject * | args | |||
| ) | [static] |
References socket_error.
| static PyObject* socket_getservbyname | ( | PyObject * | self, | |
| PyObject * | args | |||
| ) | [static] |
References socket_error.
| static PyObject* socket_getservbyport | ( | PyObject * | self, | |
| PyObject * | args | |||
| ) | [static] |
References birnlexvis::port, and socket_error.
| static PyObject* socket_htonl | ( | PyObject * | self, | |
| PyObject * | arg | |||
| ) | [static] |
| static PyObject* socket_htons | ( | PyObject * | self, | |
| PyObject * | args | |||
| ) | [static] |
| static PyObject* socket_inet_aton | ( | PyObject * | self, | |
| PyObject * | args | |||
| ) | [static] |
References INADDR_NONE, and socket_error.
| static PyObject* socket_inet_ntoa | ( | PyObject * | self, | |
| PyObject * | args | |||
| ) | [static] |
References socket_error.
| static PyObject* socket_ntohl | ( | PyObject * | self, | |
| PyObject * | arg | |||
| ) | [static] |
| static PyObject* socket_ntohs | ( | PyObject * | self, | |
| PyObject * | args | |||
| ) | [static] |
| static PyObject* socket_setdefaulttimeout | ( | PyObject * | self, | |
| PyObject * | arg | |||
| ) | [static] |
double defaulttimeout = -1.0 [static] |
PySocketModule_APIObject PySocketModuleAPI [static] |
{
&sock_type,
NULL
}
PyMemberDef sock_memberlist[] [static] |
{
{"family", T_INT, offsetof(PySocketSockObject, sock_family), READONLY, "the socket family"},
{"type", T_INT, offsetof(PySocketSockObject, sock_type), READONLY, "the socket type"},
{"proto", T_INT, offsetof(PySocketSockObject, sock_proto), READONLY, "the socket protocol"},
{"timeout", T_DOUBLE, offsetof(PySocketSockObject, sock_timeout), READONLY, "the socket timeout"},
{0},
}
PyMethodDef sock_methods[] [static] |
static PyTypeObject sock_type [static] |
Referenced by new_sockobject().
PyObject* socket_error [static] |
Referenced by gethost_common(), getsockaddrarg(), getsockaddrlen(), init_socket(), select_error(), set_error(), setipaddr(), sock_getsockopt(), socket_getaddrinfo(), socket_gethostbyaddr(), socket_getnameinfo(), socket_getprotobyname(), socket_getservbyname(), socket_getservbyport(), socket_inet_aton(), and socket_inet_ntoa().
PyObject* socket_gaierror [static] |
Referenced by init_socket(), and set_gaierror().
PyObject* socket_herror [static] |
Referenced by init_socket(), and set_herror().
PyMethodDef socket_methods[] [static] |
PyObject* socket_timeout [static] |
Referenced by init_socket(), sock_accept(), sock_connect(), sock_recv_guts(), sock_recvfrom_guts(), sock_send(), sock_sendall(), and sock_sendto().
1.6.1