Date: Fri, 10 Nov 2000 19:55:46 -0800 From: Sriranga Veeraraghavan <ranga@CSUA.Berkeley.EDU> To: j mckitrick <jcm@FreeBSD-uk.eu.org> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: programming a file transfer Message-ID: <200011110355.TAA03941@soda.csua.Berkeley.edu> In-Reply-To: Your message of "Fri, 10 Nov 2000 19:18:44 GMT." <20001110191844.A20862@dogma.freebsd-uk.eu.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200011110355.TAA03941>