From owner-freebsd-current@FreeBSD.ORG Sun Oct 10 22:56:00 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 77B3316A4CE for ; Sun, 10 Oct 2004 22:56:00 +0000 (GMT) Received: from mail.mcneil.com (mcneil.com [24.199.45.54]) by mx1.FreeBSD.org (Postfix) with ESMTP id 55C4243D1F for ; Sun, 10 Oct 2004 22:56:00 +0000 (GMT) (envelope-from sean@mcneil.com) Received: from localhost (localhost.mcneil.com [127.0.0.1]) by mail.mcneil.com (Postfix) with ESMTP id 1445AF1955 for ; Sun, 10 Oct 2004 15:56:00 -0700 (PDT) Received: from mail.mcneil.com ([127.0.0.1]) by localhost (server.mcneil.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 18768-04 for ; Sun, 10 Oct 2004 15:55:56 -0700 (PDT) Received: from [24.199.45.54] (mcneil.com [24.199.45.54]) by mail.mcneil.com (Postfix) with ESMTP id 28106F188F for ; Sun, 10 Oct 2004 15:55:56 -0700 (PDT) From: Sean McNeil To: freebsd-current@freebsd.org Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-6boT8RKXpl6Isv2o7zB4" Message-Id: <1097448955.50197.13.camel@server> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Sun, 10 Oct 2004 15:55:56 -0700 X-Virus-Scanned: by amavisd-new at mcneil.com Subject: help with multicast read (broken?) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Oct 2004 22:56:00 -0000 --=-6boT8RKXpl6Isv2o7zB4 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable I just installed 5.3-B7 on an i386 machine. All went well, but I cannot get it to read data from a multicast address. I wrote a program that works just fine on both x86 and ppc linux platforms. It does the following: struct sockaddr_in address; int reuse_addr =3D 1; int fd, i; char *stream =3D "224.1.1.1"; char *port =3D "1234"; char *buffer; buffer =3D malloc (1500); if (buffer =3D=3D NULL) { fprintf(stderr, "Cannot allocate buffer space\n"); return -1; } memset((char *) &address, 0, sizeof(address)); address.sin_family =3D AF_INET; address.sin_port =3D htons(atoi(port)); fd =3D socket(PF_INET, SOCK_DGRAM, 0); if (fd < 0) { fprintf(stderr, "Cannot open socket for stream %s\n", stream); return -1; } setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, sizeof(reuse_addr)); address.sin_addr.s_addr =3D inet_addr(stream); if (bind(fd, (struct sockaddr *) &address, sizeof(address)) < 0) { fprintf(stderr, "Cannot bind to stream %s\n", stream); close(fd); return -1; } if (IN_MULTICAST(address.sin_addr.s_addr)) { struct ip_mreq mreq;=20 mreq.imr_multiaddr.s_addr =3D address.sin_addr.s_addr; mreq.imr_interface.s_addr =3D htonl(INADDR_ANY); if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) { fprintf(stderr, "Cannot join multicast for %s\n", stream); close(fd); return -1; } } i =3D recvfrom(fd, buffer, 1500, 0, NULL, NULL); recvfrom never returns. I've looked at my program with sockstat and it has 224.1.1.1:1234 open for foreign address *:*. Anyone see a problem here? I've placed my complete program at www.mcneil.com/~sean/freebsd/stream.c you can compile simply as=20 cc -o stream stream.c I would appreciate comments/suggestions. Again, works fine under various cpus with Linux. Sean --=-6boT8RKXpl6Isv2o7zB4 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (FreeBSD) iD8DBQBBab37yQsGN30uGE4RAgMJAJ9/mqXpd10XJ2CvrRokDdAlLKUGtwCfYu9t oh/uCF/eB/YsHu8Q/AkU+uI= =Bp0U -----END PGP SIGNATURE----- --=-6boT8RKXpl6Isv2o7zB4--