Date: Tue, 4 Apr 1995 13:44:43 -0400 (EDT) From: KEITH Regan <keith@cmc.eng.comsat.com> To: FreeBSD-questions@freefall.cdrom.com Cc: marc@cmc.eng.comsat.com Subject: Binding a socket Message-ID: <Pine.3.87.9504041343.A14351-0100000@cmc>
next in thread | raw e-mail | index | archive | help
Hey - I'm having some problems with my unpatched FreeBSD 2.0 Walnut Creek CDROM. I'm am trying to bind a socket to a specific port (> 1024) with address INADDR_ANY using the TCP protocol in the Inet domain with the REUSEADDR and REUSEPORT options enabled and I get the EADDRINUSE error. I looked at what I believe to be the netinet source code for "bind" processing (in_pcb.c) and it is unclear why in in_pcbbind near: return (error); t = in_pcblookup(head, zeroin_addr, 0, sin->sin_addr, lport, wild); if (t && (reuseport & t->inp_socket->so_options) == 0) return (EADDRINUSE); there is this check against the option settings of the in_pcblookup results. It would seem that, if reuseport is ever true (and in my case it is (I think)), then any "sin" address will always be declared in use even if it has never been in use. I have verified this. With REUSEADDR and REUSEPORT not enabled, the bind works. With them enabled, it does not. I've tried just using REUSEADDR, and while I can get the bind to work, any subsequent attempt at "reusing" the port results in the same error. Whatdayathink? Do I have it all wrong? It there some clever work around or patch that I can use to move on? Thanx in advance. --- keith@cmc.eng.comsat.com --- /~~~~~\ /~~~~\ /~\ /~\ |~~~~\ /~~\ |~~~~~~~| Keith G. Regan | |---/ | /~~\ | | \/ | | +-| / /\ \ |--| |--| Director | | | | | | | \ / | \ \ | [<>] | | | Software Engineering | |---\ | \__/ | | |\/| | |-+ | | | | | | | Comsat Mobile Comm. \_____/ \____/ |_| |_| \____/ |_| |_| |_| 22300 Comsat Drive Clarksburg, MD 78720 Tel: (301) 428-2348 M O B I L E C O M M U N I C A T I O N S Fax: (301) 601-5959
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.3.87.9504041343.A14351-0100000>