From owner-freebsd-net Mon Oct 11 17:18:40 1999 Delivered-To: freebsd-net@freebsd.org Received: from cheddar.netmonger.net (cheddar.netmonger.net [209.54.21.140]) by hub.freebsd.org (Postfix) with ESMTP id 34DBE14A2C for ; Mon, 11 Oct 1999 17:18:37 -0700 (PDT) (envelope-from chris@cheddar.netmonger.net) Received: (from chris@localhost) by cheddar.netmonger.net (8.8.8/8.8.8) id UAA13277; Mon, 11 Oct 1999 20:18:01 -0400 (EDT) Message-ID: <19991011201800.A11154@netmonger.net> Date: Mon, 11 Oct 1999 20:18:01 -0400 From: Christopher Masto To: Brian Somers , Ernie Elu Cc: freebsd-net@FreeBSD.ORG Subject: Re: Modem race with Multilink PPP Mail-Followup-To: Brian Somers , Ernie Elu , freebsd-net@FreeBSD.ORG References: <199910092323.JAA18223@spooky.eis.net.au> <199910110046.BAA01324@hak.lan.Awfulhak.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=envbJBWh7q8WU6mo X-Mailer: Mutt 0.91.1i In-Reply-To: <199910110046.BAA01324@hak.lan.Awfulhak.org>; from Brian Somers on Mon, Oct 11, 1999 at 01:46:16AM +0100 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii On Mon, Oct 11, 1999 at 01:46:16AM +0100, Brian Somers wrote: > This is a known problem (well, to me anyway). > > Ppp will attempt to bind() a local domain socket when MP is > established. If bind() fails, it'll try to connect(), otherwise > it'll try to listen(). If two processes are doing this at the same > time, one bind() succeeds, but the connect() of the failed process > happens before the servers listen() and fails :-( IDKWITA, but from experimentation, the connect() should block for a while and succeed shortly after the other process calls listen(). -- Christopher Masto Senior Network Monkey NetMonger Communications chris@netmonger.net info@netmonger.net http://www.netmonger.net Free yourself, free your machine, free the daemon -- http://www.freebsd.org/ --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sock_race.pl" #!/usr/local/bin/perl -w use IO::Socket; use strict; fork ? &parent : &child; sub parent { print "P $$: parent\n"; my $proto = getprotobyname('tcp'); my $s = new IO::Socket; $s->socket(AF_INET, SOCK_STREAM, $proto) or die "P $$: socket: $!"; $s->bind(pack_sockaddr_in(7890, INADDR_ANY)) or die "P $$: bind: $!"; print "P $$: waiting..\n"; sleep 5; print "P $$: listening.\n"; $s->listen(5); print "P $$: waiting..\n"; sleep 30; print "P $$: done\n"; } sub child { print "C $$: child\n"; sleep 1; print "C $$: connecting..\n"; my $c = new IO::Socket::INET(Proto => "tcp", PeerAddr => "localhost:7890") or die "C $$: connect: $!"; print "C $$: done.\n"; } --envbJBWh7q8WU6mo-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message