From owner-freebsd-hackers Fri Oct 30 22:30:27 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id WAA18382 for freebsd-hackers-outgoing; Fri, 30 Oct 1998 22:30:27 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA18375 for ; Fri, 30 Oct 1998 22:30:23 -0800 (PST) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan@dan.emsphone.com [199.67.51.101]) by freefall.freebsd.org (8.8.8/8.8.5) with ESMTP id WAA21221 for ; Fri, 30 Oct 1998 22:30:23 -0800 (PST) Received: (from dan@localhost) by dan.emsphone.com (8.9.1/8.9.1) id AAA23790; Sat, 31 Oct 1998 00:29:49 -0600 (CST) Date: Sat, 31 Oct 1998 00:29:48 -0600 From: Dan Nelson To: Alfred Perlstein , Satish Basvapatri Cc: freebsd-hackers@freefall.cdrom.com Subject: Re: Hi Message-ID: <19981031002948.A23594@emsphone.com> References: <19981031051258.24809.qmail@hotmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.94.3i In-Reply-To: ; from "Alfred Perlstein" on Sat Oct 31 00:24:35 GMT 1998 X-OS: FreeBSD 2.2.7-STABLE Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In the last episode (Oct 31), Alfred Perlstein said: > On Sat, 31 Oct 1998, Satish Basvapatri wrote: > > I have one server and many clients. Server listens at a particular > > port. The clients themselves acts as servers for other clients and > > the opeen the connection and never closes them. If the server > > crashes without closing the socket when I am trying to restart the > > server I am getting error message "port in user". Can you suggest > > is there any way to clear up this port? > > a) don't write buggy code :) > b) setup a signal handler,(i assume for SIGSEGV) keep track of all > sockets and close them in the handler > c) the client+servers could then catch the SIGPIPE on writes to > themain server as an indication to try to reconnect in "X" amount of > time, if the slave servers are performing reads, you should set them > up to timeout after some time if no data comes across and take it as > a signal to reconnect. And the correct answer is of course d) enable the socket option SO_REUSEADDR. See the Sockets FAQ at http://kipper.york.ac.uk/~vic/sock-faq, sections 4.1 and 4.5. -Dan Nelson dnelson@emsphone.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message