Issue1244

classification
Title: Problem letting system choose the port for binding UDP socket
Type: Severity: normal
Components: Library Versions: 2.5b1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: amak Nosy List: amak, asterio
Priority: Keywords:

Created on 2009-01-24.19:59:36 by asterio, last changed 2009-01-28.16:30:05 by amak.

Files
File name Uploaded Description Edit Remove
udp_bind_problem.py asterio, 2009-01-24.19:59:36 example of bind problem
Messages
msg4070 (view) Author: asterio (asterio) Date: 2009-01-24.19:59:35
When you let the system choose the port for binding a socket, 
sock.getname() returns ('0.0.0.0', 0) addres instead the real one.

But setting the port, the returned sock address if correct.

This behaviour doesn't appears in python (both win32 or linux2 
platforms) but jython2.5b0

Here some outputs of test script

== python2.5 on win32 ==
RUNNING on win32 platform: 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) 
[MSC v.1310 32 bit (Intel)]
Binding to: ('127.0.0.1', 0)
Binded to :('127.0.0.1', 1128)
send to :('127.0.0.1', 1128)
OK

== python2.4 on linux2 ==
RUNNING on linux2 platform: 2.4.5 (#2, Aug  1 2008, 02:20:59) 
[GCC 4.3.1]
Binding to: ('127.0.0.1', 0)
Binded to :('127.0.0.1', 45506)
send to :('127.0.0.1', 45506)
OK

== jython2.5b0 on linux2 ==
RUNNING on java1.6.0_0 platform: 2.5b0 (trunk:5540, Oct 31 2008, 
13:55:41) 
[OpenJDK Server VM (Sun Microsystems Inc.)]
Binding to: ('127.0.0.1', 0)
Binded to :(u'0.0.0.0', 0)
send to :(u'0.0.0.0', 0)
Traceback (most recent call last):
  File "udp_bind_problem.py", line 19, in <module>
    sock.sendto(data, address2 )
  File "/home/agp/bin/jython2.5b0/Lib/socket.py", line 936, in sendto
    raise _map_exception(jlx)
socket.error: (-1, 'Unmapped exception: java.net.SocketException: 
Invalid argument')
msg4100 (view) Author: Alan Kennedy (amak) Date: 2009-01-28.16:30:04
This is indeed a bug; thanks for reporting it and thanks for supplying
code which illustrated the problem.

Fix checked into trunk at r5992, and release 22 at r5993.

Until the next release, you can download the fixed module from SVN

https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython/Lib/socket.py
https://jython.svn.sourceforge.net/svnroot/jython/branches/Release_2_2maint/jython/Lib/socket.py
History
Date User Action Args
2009-01-28 16:30:05amaksetstatus: open -> closed
versions: + 2.5b1, - 2.5b0
nosy: + amak
messages: + msg4100
assignee: amak
resolution: fixed
2009-01-24 19:59:36asteriocreate