From owner-freebsd-net@FreeBSD.ORG Wed Jan 4 04:22:05 2006 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A9F7416A420 for ; Wed, 4 Jan 2006 04:22:05 +0000 (GMT) (envelope-from Bob.Halley@nominum.com) Received: from shell-ng.nominum.com (shell-ng.nominum.com [81.200.64.181]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4736343D60 for ; Wed, 4 Jan 2006 04:22:05 +0000 (GMT) (envelope-from Bob.Halley@nominum.com) Received: from [128.177.199.33] (vpn-33.vpn.nominum.com [128.177.199.33]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by shell-ng.nominum.com (Postfix) with ESMTP id B1EFC56821 for ; Tue, 3 Jan 2006 20:22:04 -0800 (PST) (envelope-from Bob.Halley@nominum.com) Message-ID: <43BB4D6A.8030703@nominum.com> Date: Wed, 04 Jan 2006 14:52:02 +1030 From: Bob Halley User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-net@freebsd.org References: <43BB4C59.3010800@nominum.com> In-Reply-To: <43BB4C59.3010800@nominum.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: Unexpected EADDRINUSE X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jan 2006 04:22:05 -0000 Sorry my attachments didn't make it :) # # sink.py # import socket import traceback s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('127.0.0.1', 12345)) s.listen(5) while True: try: n = s.accept()[0] d = None while d != '': d = n.recv(100) n.close() except socket.error: pass # # conn.py # import socket import traceback n = 0 while True: try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('127.0.0.1', 0)) print s.getsockname() s.connect(('127.0.0.1', 12345)) s.close() n += 1 if n > 0 and n % 1000 == 0: print n except Exception, e: traceback.print_exc() break print n