Author socketpair
Recipients socketpair
Date 2017-12-05.09:54:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1512467694.45.0.213398074469.issue32221@psf.upfronthosting.co.za>
In-reply-to
Content
https://github.com/python/cpython/pull/4724


`recvfrom` from multicast socket is painfull slow. In fact, it returns sender address in form:

`('fe80::941f:f6ff:fe04:c560%qwe', 42133, 0, 78)`
which is superfluous, since interface-name part (`%qwe`) is not actually used. Actually, scopeid (`78`) signify interface/scope/zone_id. This tuple can be used for `.sendto()` either with this interface-name-part or without.

The problem is in the performance. For each `recvrfom()`, `getnameinfo()` internally converts interface index to interface name using three syscalls, i.e. `socket(), getsockopt()?, close()` , which slows down receiving (I have not measured result, but see additional syscalls in `strace`).

In order to convert from tuple to string-based full address one may use `getnameinfo()`:
As you can see, initial interface is ignored (but without my patch it is also validated uselessly):
```
In[1]: socket.getnameinfo(('fe80::941f:f6ff:fe04:c560%qwe', 42133, 0, 78), socket.NI_NUMERICHOST)
Out[1]: ('fe80::941f:f6ff:fe04:c560%qwe', '42133')
In[2]: socket.getnameinfo(('fe80::941f:f6ff:fe04:c560', 42133, 0, 78), socket.NI_NUMERICHOST)
Out[2]: ('fe80::941f:f6ff:fe04:c560%qwe', '42133')
```
History
Date User Action Args
2017-12-05 09:54:54socketpairsetrecipients: + socketpair
2017-12-05 09:54:54socketpairsetmessageid: <1512467694.45.0.213398074469.issue32221@psf.upfronthosting.co.za>
2017-12-05 09:54:54socketpairlinkissue32221 messages
2017-12-05 09:54:54socketpaircreate