From owner-freebsd-hackers Mon Feb 12 20:13:09 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id UAA29586 for hackers-outgoing; Mon, 12 Feb 1996 20:13:09 -0800 (PST) Received: from talking (talking.talking.com [206.14.52.81]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id UAA29580 Mon, 12 Feb 1996 20:12:58 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by talking (8.6.12/8.6.12) with SMTP id UAA04520; Mon, 12 Feb 1996 20:07:19 -0800 Message-Id: <199602130407.UAA04520@talking> X-Authentication-Warning: talking.talking.com: Host localhost didn't use HELO protocol To: ejs@bfd.com (Eric J. Schwertfeger) cc: questions@FreeBSD.org, hackers@FreeBSD.org Subject: Re: Q: programming sockets source address? Date: Mon, 12 Feb 1996 20:07:18 -0800 From: Terry Braun Sender: owner-hackers@FreeBSD.org Precedence: bulk Your message dated: Mon, 12 Feb 1996 17:40:46 PST > >> So far, my initial attempts to use bind() before connect() have been a >> wash, as bind returns an errno of EADDRNOTAVAIL, regardless of which >> address I'm using. I was under the impression that bind could be used >> before a connect to set the source address. Is this wrong? Is there a >> correct way to do this (needs to be portable to Linux)? > I'm not sure what you are trying to do, but if you want to listen on a particular socket on you local machine, say on port 1520, this code will work- bindname.sin_addr.s_addr = htonl(INADDR_ANY); bindname.sin_family = AF_INET; bindname.sin_port = htons(1520); n = bind(sock, &bindname, sizeof(bindname)); \t -------- Terry Braun tab@talking.com Talking Networks, Inc. 510-525-6696