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.

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:15Andrey Waginsetrecipients: + Andrey Wagin
2015-08-25 11:28:15Andrey Waginsetmessageid: <1440502095.54.0.909214947799.issue24933@psf.upfronthosting.co.za>
2015-08-25 11:28:15Andrey Waginlinkissue24933 messages
2015-08-25 11:28:15Andrey Wagincreate