You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
(Quoting Stephen Thorne:)
I don't think it's worth having a different API functions to distinguish
between client and server datagram protocols.
For instance, this function is will do precisely what is needed and no more:
def start_serving_datagram(protocol_factory, local_addr=None, remote_addr=None, *, family=0, proto=0, flags=0)
s = socket.socket(family, proto, flags)
if local_addr:
s.bind(local_addr) # FIXME: name resolution
if remote_addr:
s.connect(remote_addr) # FIXME: name resolution
# It is, in fact, not necessary to even call bind() *or* connect(), a port will be automatically bound on the first sendto().
...
The current implementation of _SelectorDatagramTransport.sendto(data,
addr=None) should work fine.
(Guido speaking:)
I'm not sure what the name of this method should be. Maybe
create_datagram_thingie()? :-)
Note that this assumes local_addr and remote_addr are (host, port) tuples. The
alternative would be to have 4 arguments with somewhat complex rules for which
could be None. Also note that we should call yield from self.getaddrinfo(...)
on each address to avoid blocking for the name lookup in the bind() or
connect() call. Finally we need to research whether the connect() (for a UDP
socket) could ever block on any OS -- if so, we'd need to use yield from
self.sock_connect(...) instead.
Original issue reported on code.google.com by gvanrossum@gmail.com on 20 Mar 2013 at 1:07