Message249114
| Author |
Andrey Wagin |
| Recipients |
Andrey Wagin |
| Date |
2015年08月25日.11:28:15 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1440502095.54.0.909214947799.issue24933@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
In [1]: import socket
In [2]: sks = socket.socketpair(socket.AF_UNIX, socket.SOCK_DGRAM)
In [3]: sks[1].send("asdfasdfsadfasdfsdfsadfsdfasdfsdfasdfsadfa")
Out[3]: 42
In [4]: sks[0].recv(1, socket.MSG_PEEK | socket.MSG_TRUNC)
Out[4]: 'a\x00\x00\x00\xc0\xbf8\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
recv() returns a buffer. The size of this buffer is equal to the size of transferred data, but only the first symbol was initialized. What is the idea of this behavior.
Usually recv(sk, NULL, 0, socket.MSG_PEEK | socket.MSG_TRUNC) is used to get a message size. What is the right way to get a message size in Python? |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2015年08月25日 11:28:15 | Andrey Wagin | set | recipients:
+ Andrey Wagin |
| 2015年08月25日 11:28:15 | Andrey Wagin | set | messageid: <1440502095.54.0.909214947799.issue24933@psf.upfronthosting.co.za> |
| 2015年08月25日 11:28:15 | Andrey Wagin | link | issue24933 messages |
| 2015年08月25日 11:28:15 | Andrey Wagin | create |
|