From: cerr on 2 Feb 2010 13:43 Hi There, I'm trying to send a UDP broadcast message to peers in my subnet using following code: struct sockaddr_in addr; int fd; string message = "Hello, World!"; if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { perror("socket"); return; } /* set up destination address */ memset(&addr,0,sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr("192.168.101.255"); addr.sin_port=htons(6767); while (1) { if (sendto(fd, message.c_str(), strlen(message.c_str()), 0,(struct sockaddr *) &addr, sizeof(addr)) != message.size()){ cout << "Error:" << strerror(errno) << endl; return; } else { cout << "sent:" << message << endl; } sleep(3); } I however do not see it showing-up in Wireshark... :( Why not? I succesfully get "sent: Hello, World!" messages on my screen :( Any clues? Thank you! -- roN
|
Pages: 1 Prev: readlink (was: defining after execution) Next: UDP broadcast |