Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Multicast in VxWorks

531 views
Skip to first unread message

Ųyvind Holmeide

unread,
Jun 19, 2000, 3:00:00 AM6/19/00
to

I am trying to use UDP multicast in VxWorks without success. I have used
the sample code from WindRiver, see below, but the sendto() command fails
with errno = 0x41. Any hints?


/* includes */
#include "vxWorks.h"
#include "taskLib.h"
#include "socket.h"
#include "netinet/in.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "sockLib.h"
#include "inetLib.h"
#include "ioLib.h"
#include "routeLib.h"

/* defines */
/* globals */
/* forward declarations */


STATUS mcastSend (char * mcastAddr, USHORT mcastPort, char * sendBuf,
int sendLen);
char * mcastRcv (char * ifAddr, char * mcastAddr, USHORT mcastPort,
int numRead);

/************************************************************************
* mcastSend - send a message to the multicast address
* This function sends a message to the multicast address
* The multicast group address to send, the port number, the pointer to the
* send buffer and the send buffer length are given as input parameters.
* RETURNS: OK if sucessful or ERROR
*/

STATUS mcastSend


char * mcastAddr, /* multicast address */
USHORT mcastPort, /* udp port number */
char * sendBuf, /* send Buffer */
int sendLen /* length of send buffer */
)


struct sockaddr_in sin;
struct sockaddr_in toAddr;
int toAddrLen;
int sockDesc;
char * bufPtr;
int len;

/* create a send and recv socket */

if ((sockDesc = socket (AF_INET, SOCK_DGRAM, 0)) < 0 )


printf (" cannot open send socket\n");
return (ERROR);
}

/* zero out the structures */
bzero ((char *)&sin, sizeof (sin));
bzero ((char *)&toAddr, sizeof (toAddr));

/* sin.sa_len = (u_char) sizeof(sin); */
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_port = htons(0);

if (bind(sockDesc, (struct sockaddr *)&sin, sizeof(sin)) != 0)


perror("bind");
if (sockDesc)
close (sockDesc);
return (ERROR);
}

toAddrLen = sizeof(struct sockaddr_in);
/* toAddr.sa_len = (u_char) toAddrLen; */
toAddr.sin_family = AF_INET;


/* initialize the address to the send */
toAddr.sin_addr.s_addr = inet_addr (mcastAddr);

/* initialize the port to send */
toAddr.sin_port = htons(mcastPort);

bufPtr = sendBuf; /* initialize the buffer pointer */

/* send the buffer */
while (sendLen > 0)


if ((len = sendto (sockDesc, bufPtr, sendLen, 0,
(struct sockaddr *)&toAddr, toAddrLen)) < 0 )


printf("mcastSend sendto errno:0x%x\n", errno );
break;
}

sendLen -= len;
bufPtr += len;

taskDelay (1); /* give a taskDelay */
}

if (sockDesc != ERROR)
close (sockDesc);

return (OK);
}


Bob DeJoie

unread,
Jun 20, 2000, 3:00:00 AM6/20/00
to
On Mon, 19 Jun 2000 15:57:58 GMT, "Øyvind Holmeide"
<oeyvind....@no.abb.com> wrote:

>
>
>I am trying to use UDP multicast in VxWorks without success. I have used
>the sample code from WindRiver, see below, but the sendto() command fails
>with errno = 0x41. Any hints?
>

<snip>


>/* sin.sa_len = (u_char) sizeof(sin); */
> sin.sin_family = AF_INET;
> sin.sin_addr.s_addr = INADDR_ANY;
> sin.sin_port = htons(0);
>
> if (bind(sockDesc, (struct sockaddr *)&sin, sizeof(sin)) != 0)
>
>
> perror("bind");
> if (sockDesc)
> close (sockDesc);
> return (ERROR);
> }
>

At this point in my initialization I configure the interface for
multicast, with somethin like :
setsockopt(send_socket,
IPPROTO_IP,
IP_MULTICAST_IF,
(char *)&sin.sin_addr.s_addr,
sizeof(sin.sin_addr.s_addr));

Then set TTL if there are any routers in that the message must
go through.

I am using 5.3.1 with the SENS and SENS upgrade patches applied.


> toAddrLen = sizeof(struct sockaddr_in);
>/* toAddr.sa_len = (u_char) toAddrLen; */
> toAddr.sin_family = AF_INET;
>
>
> /* initialize the address to the send */
> toAddr.sin_addr.s_addr = inet_addr (mcastAddr);
>
> /* initialize the port to send */
> toAddr.sin_port = htons(mcastPort);
>
> bufPtr = sendBuf; /* initialize the buffer pointer */
>
> /* send the buffer */
> while (sendLen > 0)
>
>
> if ((len = sendto (sockDesc, bufPtr, sendLen, 0,
> (struct sockaddr *)&toAddr, toAddrLen)) < 0 )
>
>
> printf("mcastSend sendto errno:0x%x\n", errno );
> break;
> }
>
> sendLen -= len;
> bufPtr += len;
>
> taskDelay (1); /* give a taskDelay */
> }
>
> if (sockDesc != ERROR)
> close (sockDesc);
>
> return (OK);
> }
>
>
>

================================================
Bob DeJoie
Kwajalein Missile Range
Republic of the Marshall Islands
email: rjde...@kmrmail.kmr.ll.mit.edu    
phone: 805-355-5855 fax: 805-355-3833
Time Zone: GMT +12 hours                     
================================================

Address M

unread,
Dec 19, 2022, 1:05:51 AM12/19/22
to
Dear All,

Can someone provide working code for Multicast receiver and sender for Vxworks 6.5.3 and 6.9
I am unable to receive the multicast response after binding.
After so many failed attempts unable to receive the data.

Current code link "https://pastebin.com/embed_js/KTn17YG2"
This code is working in ubuntu, but in vxworks after binding not able to receive packets.
Do I need to configure in L3 switch?

Thanks...
0 new messages