diff Modules/socketmodule.c @ 37069:dd49847a60d3 legacy-trunk

RFE #567972: Socket objects' family, type and proto properties are now exposed via new get...() methods.
author Georg Brandl <georg@python.org>
date Fri, 17 Mar 2006 19:17:34 +0000
parents 0bebeb393045
children 492044034a87
line wrap: on
line diff
--- a/Modules/socketmodule.c	Fri Mar 17 19:03:25 2006 +0000
+++ b/Modules/socketmodule.c	Fri Mar 17 19:17:34 2006 +0000
@@ -62,6 +62,7 @@
 */
 
 #include "Python.h"
+#include "structmember.h"
 
 #undef MAX
 #define MAX(x, y) ((x) < (y) ? (y) : (x))
@@ -2502,6 +2503,14 @@
 	{NULL,			NULL}		/* sentinel */
 };
 
+/* SockObject members */
+static PyMemberDef sock_memberlist[] = {
+       {"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},
+};
 
 /* Deallocate a socket object in response to the last Py_DECREF().
    First close the file description. */
@@ -2625,7 +2634,7 @@
 	0,					/* tp_iter */
 	0,					/* tp_iternext */
 	sock_methods,				/* tp_methods */
-	0,					/* tp_members */
+	sock_memberlist,			/* tp_members */
 	0,					/* tp_getset */
 	0,					/* tp_base */
 	0,					/* tp_dict */