Message3140

Author amak
Recipients amak, asterio
Date 2008-04-08.19:38:36
SpamBayes Score 0.005089003
Marked as misclassified No
Message-id <1207683517.49.0.996975986816.issue1021@psf.upfronthosting.co.za>
In-reply-to
Content
This problem cannot be fixed.

It happens because jython must present a unified (cpython) interface to
both client and server sockets, which are actually implemented with
different objects on java, namely ServerSocket/Channel and Socket/Channel.

The only way that jython can know what type of underlying socket to
create is to wait for the user to call a method which indicates whether
the socket is a client or a server socket. In this case, that call is
the "listen()" call. The "bind()" is not enough, since both client and
server sockets can bind to an address.

This deferred creation of sockets is why the exception appears only
during the "listen()" call on jython.

This is not an important issue. In practice, running code will most
likely wrap the socket creation, binding and listening in a single
try..except anyway, which will catch the error identically on both
cpython and jython. Consider the following vesion of your code.

#---------------------------------------------------------------------
import errno, socket

try:
  fd=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  rnetLoc = ('127.0.0.1', 9000)
  fd.setblocking(0)
  fd.bind( rnetLoc )
  fd.listen(5)
except socket.error, se:
  print "Exception binding to socket: %s" % se
  if se[0] == errno.EADDRINUSE:
    print "The address is already in use"
  raise SystemExit

while True: pass
#---------------------------------------------------------------------

So the resolution on this bug is that it is not a bug, or if it is a
bug, then it is not possible to fix it.

However, I will leave the bug open for now, to give the reporter a
chance to complain about a "wontfix" resolution.

Thanks all the same for reporting it; your input is valued.
History
Date User Action Args
2008-04-08 19:38:37amaksetspambayes_score: 0.005089 -> 0.005089003
recipients: + amak, asterio
2008-04-08 19:38:37amaksetspambayes_score: 0.005089 -> 0.005089
messageid: <1207683517.49.0.996975986816.issue1021@psf.upfronthosting.co.za>
2008-04-08 19:38:37amaklinkissue1021 messages
2008-04-08 19:38:36amakcreate