当前位置: 技术问答>linux和unix
UDP SOCKET编程,不能发送广播数据包
来源: 互联网 发布时间:2015-11-30
本文导语: 在Linux下,在使用UDP SOCKET编程时,点对点通信正常,也可以接收广播数据包,但不能发送广播数据包, remote.sin_addr.s_addr = inet_addr(192.168.0.255); remote.sin_port = htons(5000); remote.sin_family = AF_INET; iSendLen =...
在Linux下,在使用UDP SOCKET编程时,点对点通信正常,也可以接收广播数据包,但不能发送广播数据包,
remote.sin_addr.s_addr = inet_addr(192.168.0.255);
remote.sin_port = htons(5000);
remote.sin_family = AF_INET;
iSendLen = sendto(m_iSocket,apPkt,aiLen,0,(struct sockaddr *)&remote,sizeof(remote));
sendto()函数报错,getErrorCode()返回值=13;
remote.sin_addr.s_addr = inet_addr(192.168.0.255);
remote.sin_port = htons(5000);
remote.sin_family = AF_INET;
iSendLen = sendto(m_iSocket,apPkt,aiLen,0,(struct sockaddr *)&remote,sizeof(remote));
sendto()函数报错,getErrorCode()返回值=13;
|
是不是忘了设置socket的SO_BROADCAST option