Code review comment for lp://staging/~diogobaeder/txstatsd/fix-host-lookup

Revision history for this message
Diogo Baeder (diogobaeder) wrote :

Well, as far as I understood it, it doesn't create a "real connection",
only makes sure that all datagrams are delivered (when they are) to the
same host. As what we want is to send datagrams to the same host (as we
even resolve the host before sending the packets), this makes perfect
sense - and makes it cleaner to send messages, as we only have to pass
the data as an argument, instead of providing (host, port) for every
write() call.

Here, take a look at the paragraphs of the documentation that make it clear:
"A connected UDP socket is slightly different from a standard one - it
can only send and receive datagrams to/from a single address, but this
does not in any way imply a connection"
"Unlike a regular UDP protocol, we do not need to specify where to send
datagrams and are not told where they came from since they can only come
from the address to which the socket is 'connected'."

Em 27-12-2012 13:59, Sidnei da Silva escreveu:
> I'm fairly confident that calling transport.connect() does not do what you want. That sets the transport to 'connected udp' which is not what we want. See: http://twistedmatrix.com/documents/11.0.0/core/howto/udp.html#auto2
>
> Instead, you should pass host, port to the transport gateway and use them in transport.write(data, (host, port)).
>
>

« Back to merge proposal