patched-socketmodule.c File Reference

#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 charinet_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 Documentation

#define ACQUIRE_GETADDRINFO_LOCK
#define cppstring (  )     #x
#define freeaddrinfo   fake_freeaddrinfo
#define gai_strerror   fake_gai_strerror

Referenced by set_gaierror().

#define getaddrinfo   fake_getaddrinfo
#define getnameinfo   fake_getnameinfo

Referenced by makeipaddr(), and socket_getnameinfo().

#define INADDR_NONE   (-1)
#define IS_SELECTABLE (  )     ((s)->sock_fd < FD_SETSIZE || s->sock_timeout <= 0.0)
#define MAX ( x,
 )     ((x) < (y) ? (y) : (x))

Referenced by vtkImageGCR::mnbrak().

#define NI_MAXHOST   1025
#define NI_MAXSERV   32

Referenced by init_socket(), and socket_getnameinfo().

#define O_NONBLOCK   O_NDELAY
#define offsetof ( type,
member   )     ((size_t)(&((type *)0)->member))
#define PySocket_BUILDING_SOCKET
#define RELEASE_GETADDRINFO_LOCK
#define SAS2SA (  )     ((struct sockaddr *)(x))
#define SOCKETCLOSE   close

Function Documentation

static PyObject* gethost_common ( struct hostent *  h,
struct sockaddr *  addr,
int  alen,
int  af 
) [static]
static int getsockaddrarg ( PySocketSockObject *  s,
PyObject *  args,
struct sockaddr *  addr_ret,
int len_ret 
) [static]
static int getsockaddrlen ( PySocketSockObject *  s,
socklen_t *  len_ret 
) [static]
const char * inet_ntop ( int  af,
const void *  src,
char dst,
socklen_t  size 
)
int inet_pton ( int  af,
const char src,
void *  dst 
)

References INADDR_NONE.

PyMODINIT_FUNC init_socket ( void   ) 
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]
static int internal_select ( PySocketSockObject *  s,
int  writing 
) [static]
static int internal_setblocking ( PySocketSockObject *  s,
int  block 
) [static]
static PyObject* makeipaddr ( struct sockaddr *  addr,
int  addrlen 
) [static]
static PyObject* makesockaddr ( int  sockfd,
struct sockaddr *  addr,
int  addrlen,
int  proto 
) [static]
static PySocketSockObject* new_sockobject ( SOCKET_T  fd,
int  family,
int  type,
int  proto 
) [static]
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]
static PyObject* set_error ( void   )  [static]
static PyObject* set_gaierror ( int  error  )  [static]
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]
static PyObject* sock_accept ( PySocketSockObject *  s  )  [static]
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]
static PyObject* sock_connect_ex ( PySocketSockObject *  s,
PyObject *  addro 
) [static]
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]
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().

static ssize_t sock_recv_guts ( PySocketSockObject *  s,
char cbuf,
int  len,
int  flags 
) [static]
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]
static ssize_t sock_recvfrom_guts ( PySocketSockObject *  s,
char cbuf,
int  len,
int  flags,
PyObject **  addr 
) [static]
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]
static PyObject* sock_sendall ( PySocketSockObject *  s,
PyObject *  args 
) [static]
static PyObject* sock_sendto ( PySocketSockObject *  s,
PyObject *  args 
) [static]
static PyObject* sock_setblocking ( PySocketSockObject *  s,
PyObject *  arg 
) [static]
static PyObject* sock_setsockopt ( PySocketSockObject *  s,
PyObject *  args 
) [static]
static PyObject* sock_settimeout ( PySocketSockObject *  s,
PyObject *  arg 
) [static]
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]
static PyObject* socket_getdefaulttimeout ( PyObject *  self  )  [static]
static PyObject* socket_gethostbyaddr ( PyObject *  self,
PyObject *  args 
) [static]
static PyObject* socket_gethostbyname ( PyObject *  self,
PyObject *  args 
) [static]

References makeipaddr(), SAS2SA, and setipaddr().

static PyObject* socket_gethostbyname_ex ( PyObject *  self,
PyObject *  args 
) [static]
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]

Variable Documentation

double defaulttimeout = -1.0 [static]
PySocketModule_APIObject PySocketModuleAPI [static]
Initial value:
{
    &sock_type,
        NULL
}
PyMemberDef sock_memberlist[] [static]
Initial value:
 {
       {"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]
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]

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1