Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #22235

Socket Error : Address still in use (Conveting from python 1.5.2 to 2.7.1)

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!feeder3.cambriumusenet.nl!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <r32813@freescale.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'socket': 0.07; 'subject:Error': 0.07; 'hosts': 0.09; 'hp-ux': 0.09; 'tcp/ip': 0.09; 'python': 0.11; 'subject:python': 0.12; 'accepting': 0.15; 'subject: : ': 0.15; 'to:name:python-list@python.org': 0.15; '1.5.2': 0.16; 'grep': 0.16; 'port,': 0.16; 'received:169.254.3': 0.16; 'received:mgd.msft.net': 0.16; 'received:msft.net': 0.16; 'restart': 0.16; 'run,': 0.16; 'self.sock': 0.16; 'skip:z 30': 0.16; 'subject: \n ': 0.16; 'subject:still': 0.16; 'weird.': 0.16; 'converting': 0.18; 'python?': 0.18; 'header:Received:8': 0.20; 'received:169.254': 0.20; 'appears': 0.22; 'received:10.3': 0.22; 'header:In-Reply-To:1': 0.22; 'fine': 0.27; 'received:169': 0.27; 'seems': 0.28; 'port.': 0.29; 'code': 0.29; 'program,': 0.30; 'anyone': 0.30; 'especially': 0.31; 'rest': 0.32; 'there,': 0.32; 'processes': 0.33; 'received:bigfish.com': 0.33; 'skip:s 20': 0.34; 'server': 0.34; 'there': 0.35; 'hosting': 0.35; 'should': 0.35; 'happened': 0.35; 'skip:_ 10': 0.35; 'things': 0.36; 'subject:)': 0.36; 'environment.': 0.36; 'supposed': 0.36; 'does': 0.36; 'running': 0.36; 'port': 0.37; 'subject:from': 0.37; 'hello': 0.37; 'application': 0.38; 'skip:0 10': 0.38; 'client': 0.38; 'received:70': 0.38; 'to:addr:python-list': 0.39; 'how': 0.40; 'to:addr:python.org': 0.40; 'strange': 0.66; 'here': 0.66; 'genuine': 0.67; 'bound': 0.72; '2.7.1': 0.84; 'subject: (': 0.84; 'encountered': 0.91; 'following.': 0.91; 'connection.': 0.93
X-SpamScore 3
X-BigFish VS3(zzzz1202hzzz2dh2a8h668h839h8e2h8e3h93fhd25hbe9k)
X-Forefront-Antispam-Report CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI
From Wong Wah Meng-R32813 <r32813@freescale.com>
To "python-list@python.org" <python-list@python.org>
Subject Socket Error : Address still in use (Conveting from python 1.5.2 to 2.7.1)
Thread-Topic Socket Error : Address still in use (Conveting from python 1.5.2 to 2.7.1)
Thread-Index AQHNC/3NDMkhGD8sAk+drvFMvmjBYQ==
Date Tue, 27 Mar 2012 09:41:35 +0000
References <1973354.3.1332816158529.JavaMail.geo-discussion-forums@pbae2> <87haxahh51.fsf@benfinney.id.au>
In-Reply-To <87haxahh51.fsf@benfinney.id.au>
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [10.228.68.233]
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
MIME-Version 1.0
X-OriginatorOrg freescale.com
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1035.1332845840.3037.python-list@python.org> (permalink)
Lines 50
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1332845840 news.xs4all.nl 6918 [2001:888:2000:d::a6]:50224
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:22235

Show key headers only | View raw


Hello there,

I am in the midst of converting my application from python 1.5.2 to python 2.7.1 on HP-UX 11 Itanium box. 

My application server will set a listening port, accepting request from multiple clients. The code just works fine in the old python environment. E.g. when I do a lsof | grep <listening port> I got the following.

python     62602  genasm    5u  IPv4 0x7350d1f0        0t0  TCP zmy02aix02:12121 (LISTEN)
python     62602  genasm    6u  IPv4 0x744fb5f0        0t0  TCP zmy02aix02:12121->zmy02aix02-bkup:51867 (ESTABLISHED)
python     62602  genasm    7u  IPv4 0x75b959f0        0t0  TCP zmy02aix02:12121->zmy02aix02-bkup:51869 (ESTABLISHED)
python     62602  genasm    8u  IPv4 0x75a559f0        0t0  TCP zmy02aix02:12121->zmy02aix02-bkup:51873 (ESTABLISHED)

Strange things happened in python 2.7.1. Without modifying the code of how the socket was created and how the TCP/IP address was bound to the socket, it seems that every other processes that I run, which supposed to connect to the listening port as a client program, also appears to be holding a listening port. This is weird. Anyone has encountered this before especially when you were converting from an old python to a new python? Like you can see below there are 5 processes hosting the listening port of 18882.

$ lsof -i tcp | grep 18882
python  10598 r32813    3u  IPv4 0xe00000050b73e400       0t0  TCP zmy02hp3.ap.freescale.net:18882 (LISTEN)
python  18181 r32813    3u  IPv4 0xe00000050b73e400       0t0  TCP zmy02hp3.ap.freescale.net:18882 (LISTEN)
python  20025 r32813    3u  IPv4 0xe00000050b73e400       0t0  TCP zmy02hp3.ap.freescale.net:18882 (LISTEN)
python  26295 r32813    3u  IPv4 0xe00000050b73e400       0t0  TCP zmy02hp3.ap.freescale.net:18882 (LISTEN)
python  26428 r32813    3u  IPv4 0xe00000050b73e400       0t0  TCP zmy02hp3.ap.freescale.net:18882 (LISTEN)

Since only one of them is the genuine process holding the port, I need to kill off the rest of the process if I need to restart the genuine process running under that port. It should not work this way. 

Here is the code of the application process that hosts the listening port. 

	self.sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
	self.sock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 )
	self.sock.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1
	self.sock.setsockopt( socket.IPPROTO_TCP, _TCP_NODELAY, 1 )
	self.sock.bind( self.server_address )
  

Here is the client code that does the connection.

       self.sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
       self.sock.setsockopt( socket.IPPROTO_TCP, _TCP_NODELAY, 1 )
       self.sock.connect( self.server_address )

Regards,
Wah Meng

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

OAuth 2.0 implementation Demian Brecht <demianbrecht@gmail.com> - 2012-03-26 19:42 -0700
  Re: OAuth 2.0 implementation Ben Finney <ben+python@benfinney.id.au> - 2012-03-27 14:11 +1100
    Re: OAuth 2.0 implementation Roy Smith <roy@panix.com> - 2012-03-26 23:30 -0400
      Re: OAuth 2.0 implementation Ben Finney <ben+python@benfinney.id.au> - 2012-03-27 14:49 +1100
        Re: OAuth 2.0 implementation Roy Smith <roy@panix.com> - 2012-03-26 23:57 -0400
          Re: OAuth 2.0 implementation Ben Finney <ben+python@benfinney.id.au> - 2012-03-27 15:24 +1100
            Re: OAuth 2.0 implementation Jack Diederich <jackdied@gmail.com> - 2012-03-27 01:24 -0400
            Re: OAuth 2.0 implementation Demian Brecht <demianbrecht@gmail.com> - 2012-03-26 22:30 -0700
              Re: OAuth 2.0 implementation Roy Smith <roy@panix.com> - 2012-03-27 10:18 -0400
                Re: OAuth 2.0 implementation Demian Brecht <demianbrecht@gmail.com> - 2012-03-27 10:54 -0700
                Re: OAuth 2.0 implementation Mark Hammond <skippy.hammond@gmail.com> - 2012-03-28 14:42 +1100
    Re: OAuth 2.0 implementation Stuart Bishop <stuart@stuartbishop.net> - 2012-03-27 16:59 +0700
    Socket Error : Address still in use  (Conveting from python 1.5.2 to 2.7.1) Wong Wah Meng-R32813 <r32813@freescale.com> - 2012-03-27 09:41 +0000
    Re: OAuth 2.0 implementation Roland Hedberg <roland@catalogix.se> - 2012-03-27 15:36 +0200
  Re: OAuth 2.0 implementation Demian Brecht <demianbrecht@gmail.com> - 2012-07-05 07:06 -0700
    Re: OAuth 2.0 implementation Alec Taylor <alec.taylor6@gmail.com> - 2012-07-06 01:19 +1000
      Re: OAuth 2.0 implementation Demian Brecht <demianbrecht@gmail.com> - 2012-07-05 10:48 -0700
      Re: OAuth 2.0 implementation Demian Brecht <demianbrecht@gmail.com> - 2012-07-05 10:48 -0700
        Re: OAuth 2.0 implementation Demian Brecht <demianbrecht@gmail.com> - 2012-07-06 08:38 -0700
        Re: OAuth 2.0 implementation Demian Brecht <demianbrecht@gmail.com> - 2012-07-06 08:38 -0700
          Re: OAuth 2.0 implementation Alec Taylor <alec.taylor6@gmail.com> - 2012-07-07 04:41 +1000
          RE: OAuth 2.0 implementation "Demian Brecht" <demianbrecht@gmail.com> - 2012-07-06 11:49 -0700
          Re: OAuth 2.0 implementation Alec Taylor <alec.taylor6@gmail.com> - 2012-07-07 04:58 +1000

csiph-web