From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16150 invoked by alias); 10 Sep 2003 08:43:08 -0000 Mailing-List: contact ecos-discuss-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@sources.redhat.com Received: (qmail 16141 invoked from network); 10 Sep 2003 08:43:07 -0000 Received: from unknown (HELO cwarens1.controlware.de) (193.22.120.157) by sources.redhat.com with SMTP; 10 Sep 2003 08:43:07 -0000 Received: from controlware.de (localhost.controlware.de [127.0.0.1]) by cwarens1.controlware.de (Postfix) with SMTP id 131F12BC3B for ; Wed, 10 Sep 2003 10:43:06 +0200 (CEST) Received: from DE#u#POST-Message_Server by controlware.de with Novell_GroupWise; Wed, 10 Sep 2003 10:43:06 +0200 Message-Id: Date: Wed, 10 Sep 2003 08:43:00 -0000 From: "Adolfo Lucha" To: andrew@lunn.ch Cc: ecos-discuss@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: [ECOS] Antw: Re: [ECOS] Receiving Multicast Packets on a socket X-SW-Source: 2003-09/txt/msg00170.txt.bz2 Hello Andrew, thanks fir hint. http://www.infres.enst.fr/~dax/polys/multicast/api_en.html= is a good example. I will try it. Thangs and Regards Adolfo >>> Andrew Lunn 10.09.03 09.43 >>> On Wed, Sep 10, 2003 at 09:09:45AM +0200, Adolfo Lucha wrote: > Hello, >=20 > I tried to receive Packets sent by routers to the multicast address 224.0= .0.2. I coded: >=20 > ...cat... >=20 > int one =3D 1; >=20=20=20=20=20 > s =3D socket(AF_INET, SOCK_DGRAM, 0); >=20 > if (s < 0) > { > printf("datagram socket failed"); > return -1; > } >=20=20=20=20=20 > if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one))) > { > printf("setsockopt SO_BROADCAST error"); > return -1; > } >=20=20=20=20=20 > memset(&local, 0, sizeof(local)); > local.sin_family =3D AF_INET; > local.sin_len =3D sizeof(local); > local.sin_port =3D htons(HSRP_PORT_NUMBER); > local.sin_addr.s_addr =3D inet_addr("224.0.0.2"); // or INADDR_ANY ? >=20=20=20=20=20 > if(bind(s, (struct sockaddr *) &local, sizeof(local)) < 0) > { > printf("bind error"); > return -1; > } >=20 > ret =3D recvfrom(s, &HsrpPacket, sizeof(HsrpPacket), (int)0,\ > (struct sockaddr *)&client_addr, (socklen_t = *)&client_addr_len); >=20 > ...cat... >=20 > But recvfrom() never returns. What am I doing wrong? Hints are appreciate= d. You need to join the multicast group. Find a book/HOWTO etc about writing multicast programs. eCos uses the standard BSD API, so normal networking books are OK. Andrew -- Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos and search the list archive: http://sources.redhat.com/ml/ecos-discuss