阅读:6513回复:4
VxWorks 组播sendto() error 0x41
程序设置如下:
bzero ((char *)&sMAddr, sizeof (sMAddr)); sMAddr.sin_len = (u_char) sizeof(sMAddr); sMAddr.sin_family = AF_INET; /*sMAddr.sin_addr.s_addr =inet_addr(MyIP);*/ sMAddr.sin_addr.s_addr = INADDR_ANY; sMAddr.sin_port =htons(6677); mTolen=sizeof (mToAddr); bzero ((char *)&mToAddr, sizeof (mToAddr)); mToAddr.sin_len = (u_char) sizeof(mToAddr); mToAddr.sin_family = AF_INET; mToAddr.sin_addr.s_addr = inet_addr("224.1.*.*");; (我的组播ip) mToAddr.sin_port =htons(5512); if ((sMSock = socket (AF_INET, SOCK_DGRAM, 0)) < 0 ) { printf ("\nThere is error r socket!\n"); perror ("socket"); return 1; } if (bind(sMSock, (struct sockaddr *)&sMAddr, sizeof(sMAddr)) != 0) { perror("bind"); return 1; } for (i=0;i <50;i++) { pMbuf=i+1; } setsockopt(sMSock, IPPROTO_IP, IP_ADD_MEMBERSHIP,\ (char *)&mToAddr, sizeof(mToAddr)); buf=pMbuf; for(;;) { while (len> 0) { if ((sendlen = sendto (sMSock, buf , len, 0, (struct sockaddr *)&mToAddr,mTolen)) < 0 ) { printf("mcastSend sendto errno:0x%x\n", errno ); break; } ..... 局域网 , 路由器 , 双网卡的错误? 附:-> ifShow fei (unit number 0): Flags: (0x8063) UP BROADCAST RUNNING ARP MULTICAST Type: ETHERNET_CSMACD Internet address: 199.10.10.88 Broadcast address: 199.10.10.255 Netmask 0xffffff00 Subnetmask 0xffffff00 Ethernet address is 00:1d:f3:20:0f:c1 Metric is 0 Maximum Transfer Unit size is 1500 1431 packets received; 107 packets sent 1430 multicast packets received 1 multicast packets sent 0 input errors; 0 output errors 0 collisions; 0 dropped lo (unit number 0): Flags: (0x8069) UP LOOPBACK RUNNING ARP MULTICAST Type: SOFTWARE_LOOPBACK Internet address: 127.0.0.1 Netmask 0xff000000 Subnetmask 0xff000000 Metric is 0 Maximum Transfer Unit size is 32768 0 packets received; 0 packets sent 0 multicast packets received 0 multicast packets sent 0 input errors; 0 output errors 0 collisions; 0 dropped fei (unit number 1): Flags: (0x8063) UP BROADCAST RUNNING ARP MULTICAST Type: ETHERNET_CSMACD Internet address: 128.9.223.2 Broadcast address: 128.9.223.255 Netmask 0xffff0000 Subnetmask 0xffffff00 Ethernet address is 00:1d:f3:20:0f:c2 Metric is 0 Maximum Transfer Unit size is 1500 0 packets received; 1 packets sent 0 multicast packets received 0 multicast packets sent 0 input errors; 0 output errors 0 collisions; 0 dropped value = 0 = 0x0 -> ??????????????????? |
|
|
沙发#
发布于:2009-02-17 21:47
看看你的网络数据堆栈看看冒了没有???
|
|
板凳#
发布于:2010-04-09 15:04
你的问题解决了?我现在也遇到这个问题,只要目的端地址是组播地址sendto就是-1,错误代码0x41,是什么原因?
另,能接收组播信息。 |
|
地板#
发布于:2012-04-16 21:15
添加个路由吧。
|
|
地下室#
发布于:2017-12-30 17:59
用户被禁言,该主题自动屏蔽! |
|