Opened 16 years ago

Closed 12 years ago

#1363 enhancement closed fixed (fixed)

broadcasting over udp causes warning

Reported by: antony Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: itamarst, antony, jesstess Branch: branches/udp-broadcast-warning-1363
branch-diff, diff-cov, branch-cov, buildbot
Author: jesstess


Attachments (1)

udp.diff (515 bytes) - added by antony 16 years ago.

Download all attachments as: .zip

Change History (14)

Changed 16 years ago by antony

Attachment: udp.diff added

comment:1 Changed 16 years ago by antony

when sending messages over udp to host "<broadcast>", Twisted complains it is
not an IP address and that it should be resolved first. This is obviously
unnecessary. The attached patch fixes it.

comment:2 Changed 16 years ago by itamarst

Uh. What is address "<broadcast>"? Where is it documented?

comment:3 Changed 16 years ago by antony

Well, I don't know much about it myself, and it seems to be extremely poorly
documented. Here are some references:

1. Here '' is used:

2. This is a module in Pyro:
And here's a quote from there: """
# No host specified. Use broadcast mechanism
		# Jython handling for broadcast addrs
		destination1 = ('', port1)
		destination2 = ('', port2)
		# regular python broadcast socket
		destination1 = ('<broadcast>', port1)
		destination2 = ('<broadcast>', port2)

3. Try """socket.gethostbyname("<broadcast>")""". It returns ''.
From looking at the Python source code, the conversion doesn't seem to be blocking.

comment:4 Changed 16 years ago by itamarst

So, can't you just use in your code?

comment:5 Changed 16 years ago by antony

I can, but why prevent the seemingly legitimate alternative of "<broadcast>"?
The Python sources indicate that the two possibilities are simply the same, so
if one is accepted, the other shouldn't cause a warning saying that it should be
resolved first, which is quite irrelevant.

Also, since this thing is poorly documented, if some poor user finds code using
"<broadcast>" and wants to adapt it to Twisted, they're going to run into
needless trouble trying to address the issue of this warning, get their time
wasted, and possibily entertain a fleeting emotion of resentment towards
Twisted, all very negative outcomes! :)

comment:6 Changed 14 years ago by Jean-Paul Calderone

Summary: [PATCH] broadcasting over udp causes warningbroadcasting over udp causes warning

This would be good. The patch needs a unit test, though. It should be pretty straightforward.

comment:7 Changed 12 years ago by jesstess

Owner: set to jesstess

comment:8 Changed 12 years ago by jesstess

Author: jesstess
Branch: branches/udp-broadcast-warning-1363

(In [28551]) Branching to 'udp-broadcast-warning-1363'

comment:9 Changed 12 years ago by jesstess

(In [28552]) Add unit test for no deprecation warning in <broadcast> case.

refs #1363

comment:10 Changed 12 years ago by jesstess

Cc: jesstess added
Keywords: review added
Owner: jesstess deleted has some coding standards issues. Outside of write() I only fixed the locations of triple-quotes in docstrings since that happens to particularly bother me.

comment:11 Changed 12 years ago by therve

Keywords: review removed
Owner: set to jesstess

Looks good. Please make sure it runs correctly with a buildbot run, then merge.

comment:12 Changed 12 years ago by jesstess

Resolution: fixed
Status: newclosed

(In [28577]) Merge udp-broadcast-warning-1363

Authors: antony, jesstess Reviewers: exarkun, therve Fixes: #1363

'<broadcast>' is an alternative way to say '' (socket.gethostbyname("<broadcast>") returns ''), so don't emit a deprecation warning in twisted.internet.udp.Port.write about passing hostnames instead of IP addresses for this special '<broadcast>' case.

comment:13 Changed 11 years ago by <automation>

Owner: jesstess deleted
Note: See TracTickets for help on using tickets.