Message249114
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? |
|
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 | |
|