public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Antw: Re: [ECOS] Receiving Multicast Packets on a socket
@ 2003-09-10  8:43 Adolfo Lucha
  0 siblings, 0 replies; only message in thread
From: Adolfo Lucha @ 2003-09-10  8:43 UTC (permalink / raw)
  To: andrew; +Cc: ecos-discuss

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 <andrew@lunn.ch> 10.09.03 09.43 >>>
On Wed, Sep 10, 2003 at 09:09:45AM +0200, Adolfo Lucha wrote:
> Hello,
> 
> I tried to receive Packets sent by routers to the multicast address 224.0.0.2. I coded:
> 
> ...cat...
> 
>     int one = 1;
>     
>     s = socket(AF_INET, SOCK_DGRAM, 0);
> 
>     if (s < 0)
>     {
>     	printf("datagram socket failed");
>     	return -1;
>     }
>     
>     if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one)))
>     {
>     	printf("setsockopt SO_BROADCAST error");
>     	return -1;
>     }
>     
>     memset(&local, 0, sizeof(local));
>     local.sin_family = AF_INET;
>     local.sin_len    = sizeof(local);
>     local.sin_port   = htons(HSRP_PORT_NUMBER);
>     local.sin_addr.s_addr = inet_addr("224.0.0.2"); // or INADDR_ANY ?
>     
>     if(bind(s, (struct sockaddr *) &local, sizeof(local)) < 0)
>     {
>     	printf("bind error");
>     	return -1;
>     }
> 
>     ret = recvfrom(s, &HsrpPacket, sizeof(HsrpPacket), (int)0,\
>                              (struct sockaddr *)&client_addr, (socklen_t *)&client_addr_len);
> 
> ...cat...
> 
> But recvfrom() never returns. What am I doing wrong? Hints are appreciated.

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-09-10  8:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-10  8:43 [ECOS] Antw: Re: [ECOS] Receiving Multicast Packets on a socket Adolfo Lucha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).