Wxforwarramsocket broadcast [posting 16:08:29] font size: Medium and Small wxsocketbase: Initialize (); wxipv4address broadcastaddress; // for broadcast sending wxipv4address localaddress; // For the listening localaddress. anyaddress (); broadcastaddress. hostname (_ ("255.255.255.255"); broadcastaddress. service (1667); // port on which we listen for the answers localaddress. service (1667); // port on which we listen for the answers // create the socket wx?ramsocket * socket = new wx=ramsocket (localaddress, wxsocket_reuseaddr); static const int B = 1; socket-> setoption (sol_socket, so_broadcast, & B, sizeof (B); char * message = "hello"; socket-> sendto (broadcastaddress, message, strlen (Message); // check for any errors int COUNT = socket-> lastcount (); If (socket-> error ()) {wxsocketerror err = socket-> lasterror ();} wxsocketbase: Shutdown ();
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service