Thanks. Someone pointed out that this could be due to a corrupted build, which I revisited the process. I included -lxnet in the linking process of the build, and this problem is resolved. The -lxnet was stated in README file for HP-UX Itanium build, which I somehow dropped it out in the middle of the process and wasn't aware it was essential as excluding it cost me the junk I was seeing. Problem solved!! Thanks a lot for reverting. :)
Regards, Wah Meng -----Original Message----- From: python-list-bounces+wahmeng=freescale....@python.org [mailto:python-list-bounces+wahmeng=freescale....@python.org] On Behalf Of Gabriel Genellina Sent: Friday, October 07, 2011 5:37 PM To: python-list@python.org Subject: Re: socket.getsockname is returning junk!! En Wed, 05 Oct 2011 08:56:08 -0300, Wong Wah Meng-R32813 <r32...@freescale.com> escribió: > I am migrating my application from python 1.5.2 to 2.7.1. One of the > existing code breaks. The getsockname method from socket object somehow > returns me with some number which I deem as junk, rather than the > listening port as I would have expected in the older python. Has anyone > seen the same thing or is it due to my python is built with some > corrupted library or something? > > > $ python > Python 2.7.1 (r271:86832, Oct 5 2011, 18:34:15) [C] on hp-ux11 > Type "help", "copyright", "credits" or "license" for more information. >>>> import socket >>>> sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) >>>> sock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 ) >>>> sock.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1 ) >>>> sock.setsockopt( socket.IPPROTO_TCP, 1, 1 ) >>>> server_address=('zmy02hp3', 11111) >>>> sock.bind(server_address) >>>> sock.getsockname() > (0, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') > > In python 1.5.2 >>>> server_address=('zmy02aix04', 11111) >>>> sock.bind(server_address) >>>> sock.getsockname() > ('10.228.51.41', 11111) I'd say it's a problem with the _socket module; did the unit tests flag anything when you built Python? On Windows, Python 2.7.1: >>> server_address=('lepton', 11111) >>> sock.bind(server_address) >>> sock.getsockname() ('127.0.0.1', 11111) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list