const char *paddr_operator_multicast = “239.2.1.1”;
void op_sendto(u8 u8index, u8 u8port, void *pbuffer, u32 u32len)
{
u32 i;
int iret;
u32 u32addr = u8index;
struct sockaddr_in addr;
struct in_addr in_addr_ip;
struct hostent *hp;
if (NULL == pbuffer)
{
ERROR(“operator - sendto buffer error”);
return;
}
if (u8index > 1)
{
ERROR(“operator - sendto ccr index error”);
return;
}
if (-1 == iop_socket[u8port])
{
ERROR(“operator - sendto socket error”);
return;
}
/get target ip/
//hp = gethostbyname(paddr_operator_ccr[u8index]);
hp = gethostbyname(paddr_operator_multicast);
if (NULL != hp)
{
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
memcpy(&addr.sin_addr, hp->h_addr, hp->h_length);
//addr.sin_port = htons(OP_IP_PORT_TX + u8port * 2);
addr.sin_port = htons(OP_IP_PORT_BASE + u8sys_index);
usleep(1);
iret = sendto(iop_socket[u8port], (void *)pbuffer, u32len, 0, (struct sockaddr *)&addr, sizeof(addr));
if (-1 == iret)
{
ERROR(“operator - sendto send error %d”, errno);
}
// printf(“u32len is %d\n”,u32len);
}
}
运行后发现[ERROR]op_sendto(L719): operator - sendto send error 265