Opened 11 years ago

Closed 6 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

Description


Attachments (1)

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

Download all attachments as: .zip

Change History (14)

Changed 11 years ago by antony

comment:1 Changed 11 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 11 years ago by itamarst

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

comment:3 Changed 11 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 '255.255.255.255' is used:
http://www.knowdotnet.com/articles/udpbroadcastmessage.html

2. This is a module in Pyro:
http://cvs.sourceforge.net/viewcvs.py/pyro/Pyro/Pyro/naming.py?view=markup
And here's a quote from there: """
# No host specified. Use broadcast mechanism
	if os.name=='java':
		# Jython handling for broadcast addrs
		destination1 = ('255.255.255.255', port1)
		destination2 = ('255.255.255.255', port2)
	else:
		# regular python broadcast socket
		destination1 = ('<broadcast>', port1)
		destination2 = ('<broadcast>', port2)
"""

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

comment:4 Changed 11 years ago by itamarst

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

comment:5 Changed 11 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 8 years ago by exarkun

  • Summary changed from [PATCH] broadcasting over udp causes warning to broadcasting over udp causes warning

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

comment:7 Changed 6 years ago by jesstess

  • Owner set to jesstess

comment:8 Changed 6 years ago by jesstess

  • Author set to jesstess
  • Branch set to branches/udp-broadcast-warning-1363

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

comment:9 Changed 6 years ago by jesstess

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

refs #1363

comment:10 Changed 6 years ago by jesstess

  • Cc jesstess added
  • Keywords review added
  • Owner jesstess deleted

udp.py 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 6 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 6 years ago by jesstess

  • Resolution set to fixed
  • Status changed from new to closed

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

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

'<broadcast>' is an alternative way to say '255.255.255.255' (socket.gethostbyname("<broadcast>") returns '255.255.255.255'), 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 5 years ago by <automation>

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