This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2013年05月29日 14:07 by Roman.Valov, last changed 2022年04月11日 14:57 by admin.
| Messages (2) | |||
|---|---|---|---|
| msg190308 - (view) | Author: Roman Valov (Roman.Valov) | Date: 2013年05月29日 14:07 | |
There is a way to "disconnect" UDP socket that was previously "connected" to specific remote endpoint in C: struct sockaddr_in sin; memset((char *)&sin, 0, sizeof(sin)); sin.sin_family = AF_UNSPEC; connect(fd, (struct sockaddr *)&sin, sizeof(sin)); However in this is not available in python, since connect accepts only (host, port) as a parameter for UDP socket. It's possible to drop "port" connection with port=0, however I can't find a way to drop "host" connection. |
|||
| msg192479 - (view) | Author: Martin Gergov (marto1) | Date: 2013年07月06日 18:34 | |
--- a/Modules/socketmodule.c Tue Jul 02 09:07:53 2013 -0400
+++ b/Modules/socketmodule.c Sat Jul 06 21:08:40 2013 +0300
@@ -3673,6 +3673,15 @@
{
int how;
int res;
+ struct sockaddr_in sin;
+ if (s->sock_type == SOCK_DGRAM){
+ memset((char *)&sin, 0, sizeof(sin));
+ sin.sin_family = AF_UNSPEC;
+ Py_BEGIN_ALLOW_THREADS
+ res = connect(s->sock_fd, (struct sockaddr *)&sin, sizeof(sin));
+ Py_END_ALLOW_THREADS
+ return Py_None;
+ }
how = _PyLong_AsInt(arg);
if (how == -1 && PyErr_Occurred())
The shutdown method seems a suitable candidate, but a disconnect() method(which is semantically more correct) could be introduced.
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:46 | admin | set | github: 62295 |
| 2013年07月06日 18:42:10 | giampaolo.rodola | set | nosy:
+ giampaolo.rodola |
| 2013年07月06日 18:34:03 | marto1 | set | nosy:
+ marto1 messages: + msg192479 |
| 2013年05月29日 14:07:24 | Roman.Valov | create | |