linux下udp广播不成功,求助?
在同一个系统下,启动udpserv,运行:udpcli 255.255.255.255,接收端口收不到消息,如果换成udp 255.* 或者udp localhost 都可以收到,唯独255.255.255.255不行,代码如下,帮忙看看是什么问题,是不是setsockopt有错
udpcli.cpp(发送端):C/C++ code#include //connect,send,recv,setsockoptµÈ
#include
#include // sockaddr_in, “man 7 ip” ,htons
#include //poll,pollfd
#include //inet_addr,inet_aton
#include //read,write
#include //gethostbyname
#include //perror
#include
#include //errno
#include
#include // memset
#include
#define MAXLINE 4096
#define EHCO_PORT 9877
#define BOOL unsigned char
int main(int argc, char **argv)
{
int sockfd;
struct sockaddr_in servaddr;
if(argc != 2)
err_quit(“usage: udpcli