From owner-freebsd-net Wed Sep 22 23:46:27 1999 Delivered-To: freebsd-net@freebsd.org Received: from sttlpop5.sttl.uswest.net (sttlpop5.sttl.uswest.net [206.81.192.5]) by hub.freebsd.org (Postfix) with SMTP id 1DD6315516 for ; Wed, 22 Sep 1999 23:46:17 -0700 (PDT) (envelope-from nchong@uswest.net) Received: (qmail 415 invoked by alias); 23 Sep 1999 06:46:17 -0000 Delivered-To: fixup-freebsd-net@freebsd.org@fixme Received: (qmail 404 invoked by uid 0); 23 Sep 1999 06:46:16 -0000 Received: from ddslppp190.sttl.uswest.net (HELO gchunghome) (216.160.75.190) by sttlpop5.sttl.uswest.net with SMTP; 23 Sep 1999 06:46:16 -0000 From: "N. C. Hong" To: Subject: FreeBSD 3.2 bug when calling connect on a UDP socket? Date: Wed, 22 Sep 1999 23:48:51 -0700 Message-ID: <000201bf058f$b27c0e40$0200000a@gchunghome> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On FreeBSD 3.2, when running two instances of the following program, the second instance fails during the connect call. It works fine on Windows NT. I haven't tested on other platforms. I don't see any reason why two UDP sockets bound to the same port on the same host can't both be "connected" to a multicast endpoint. #include #include #include #include #include #include #include #include void checkError(int status) { if (status < 0) { fprintf(stderr, "SOCKET ERROR: %d\n", errno); assert(0); } } void main() { int status; struct sockaddr_in sa; printf("before socket\n"); int sockfd = socket(AF_INET, SOCK_DGRAM, 0); checkError(sockfd); printf("after socket\n"); printf("before setsockopt SO_REUSEPORT\n"); const int on = 1; status = setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)); checkError(status); printf("after setsockopt SO_REUSEPORT\n"); printf("before bind\n"); bzero(&sa, sizeof(sa)); sa.sin_family = AF_INET; sa.sin_port = htons(10000); sa.sin_addr.s_addr = htonl(INADDR_ANY); status = bind(sockfd, (const sockaddr *)&sa, sizeof(sa)); checkError(status); printf("after bind\n"); printf("before connect\n"); bzero(&sa, sizeof(sa)); sa.sin_family = AF_INET; sa.sin_port = htons(10001); sa.sin_addr.s_addr = inet_addr("225.0.0.1"); status = connect(sockfd, (const struct sockaddr *)&sa, sizeof(sa)); checkError(status); printf("after connect\n"); printf("before recvfrom\n"); char buf[8192]; status = recvfrom(sockfd, buf, 8192, 0, 0, 0); checkError(status); printf("after recvfrom\n"); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message