]> granicus.if.org Git - python/commitdiff
Patch #849595: Add socket.shutdown() constants.
authorMartin v. Löwis <martin@v.loewis.de>
Thu, 27 Nov 2003 19:40:22 +0000 (19:40 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Thu, 27 Nov 2003 19:40:22 +0000 (19:40 +0000)
Doc/lib/libsocket.tex
Misc/NEWS
Modules/socketmodule.c

index de2f51d89160f156a4fcf132b4284a5ff511dd03..09c4c8d63ada461278143dc6eece71f8d569a4d5 100644 (file)
@@ -638,8 +638,8 @@ structures as strings).
 
 \begin{methoddesc}[socket]{shutdown}{how}
 Shut down one or both halves of the connection.  If \var{how} is
-\code{0}, further receives are disallowed.  If \var{how} is \code{1},
-further sends are disallowed.  If \var{how} is \code{2}, further sends
+\constant{SHUT_RD}, further receives are disallowed.  If \var{how} is \constant{SHUT_WR},
+further sends are disallowed.  If \var{how} is \constant{SHUT_RDWR}, further sends
 and receives are disallowed.
 \end{methoddesc}
 
index c9b7baa1c69cf4de4a1ae9d6197256bec28e2580..c523e65f7ae5711e3dbdef8ecb569fbe4268170f 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -95,6 +95,8 @@ Core and builtins
 Extension modules
 -----------------
 
+- socket.SHUT_{RD,WR,RDWR} was added.
+
 - os.getsid was added.
 
 - The pwd module incorrectly advertised its struct type as
index f93da4ec0767597c97635ded6d833dc2e42693e3..6ca855f6695d3dde1f6be71b2928659e988a0697 100644 (file)
@@ -2097,8 +2097,8 @@ sock_shutdown(PySocketSockObject *s, PyObject *arg)
 PyDoc_STRVAR(shutdown_doc,
 "shutdown(flag)\n\
 \n\
-Shut down the reading side of the socket (flag == 0), the writing side\n\
-of the socket (flag == 1), or both ends (flag == 2).");
+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).");
 
 
 /* List of methods for socket objects */
@@ -4101,6 +4101,29 @@ init_socket(void)
        PyModule_AddIntConstant(m, "NI_DGRAM", NI_DGRAM);
 #endif
 
+       /* shutdown() parameters */
+#ifdef SHUT_RD
+       PyModule_AddIntConstant(m, "SHUT_RD", SHUT_RD);
+#elif defined(SD_RECEIVE)
+       PyModule_AddIntConstant(m, "SHUT_RD", SD_RECEIVE);
+#else
+       PyModule_AddIntConstant(m, "SHUT_RD", 0);
+#endif
+#ifdef SHUT_WR
+       PyModule_AddIntConstant(m, "SHUT_WR", SHUT_WR);
+#elif defined(SD_SEND)
+       PyModule_AddIntConstant(m, "SHUT_WR", SD_SEND);
+#else
+       PyModule_AddIntConstant(m, "SHUT_WR", 1);
+#endif
+#ifdef SHUT_RDWR
+       PyModule_AddIntConstant(m, "SHUT_RDWR", SHUT_RDWR);
+#elif defined(SD_BOTH)
+       PyModule_AddIntConstant(m, "SHUT_RDWR", SD_BOTH);
+#else
+       PyModule_AddIntConstant(m, "SHUT_RDWR", 2);
+#endif
+
        /* Initialize gethostbyname lock */
 #if defined(USE_GETHOSTBYNAME_LOCK) || defined(USE_GETADDRINFO_LOCK)
        netdb_lock = PyThread_allocate_lock();