From owner-freebsd-questions Fri Nov 10 19:57: 6 2000 Delivered-To: freebsd-questions@freebsd.org Received: from soda.csua.Berkeley.edu (soda.CSUA.Berkeley.EDU [128.32.43.52]) by hub.freebsd.org (Postfix) with ESMTP id F285237B479 for ; Fri, 10 Nov 2000 19:57:03 -0800 (PST) Received: from soda.csua.Berkeley.edu (localhost [127.0.0.1]) by soda.csua.Berkeley.edu (8.8.8/) via ESMTP id TAA03941; Fri, 10 Nov 2000 19:55:46 -0800 (PST) env-from (ranga@CSUA.Berkeley.EDU) Message-Id: <200011110355.TAA03941@soda.csua.Berkeley.edu> To: j mckitrick Cc: freebsd-questions@FreeBSD.ORG Subject: Re: programming a file transfer In-Reply-To: Your message of "Fri, 10 Nov 2000 19:18:44 GMT." <20001110191844.A20862@dogma.freebsd-uk.eu.org> Date: Fri, 10 Nov 2000 19:55:46 -0800 From: Sriranga Veeraraghavan Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, Sounds like you probably want need to use setsockopt(2), specifically the SO_REUSEADDR. This option allows a process to bind to a well-known port even if other connections already use that port. For more info see Stevens, Unix Network Programming Volume 1 2nd edition, pg 194. Some people like SO_LINGER better than SO_REUSEADDR, but Stevens says to use not to use SO_LINGER for various reasons (pg 187). After you create the socket via socket(2), you should probably call setsockopt similar to the following to get the desired behavior: int flags = 1; ... if (setsockopt(sock_listen, SOL_SOCKET, SO_REUSEADDR, (void *)&flags, sizeof(flags)) < 0) { close(sock_listen); perror("Error"); } HTH, ----ranga To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message