Network UDP broadcast design?

前端 未结 3 1790
借酒劲吻你
借酒劲吻你 2021-01-31 10:46

I am working on a C++ server/.NET client applications couple in which my server (which runs the c++ on linux) broadcasts a message to show it\'s alive to the whole network and m

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-31 11:26

    You also have to enable the SO_BROADCAST socket option in C++ to send broadcast traffic, or you'll get a permission denied error:

    int broadcastPermission = 1;
    setsockopt(socketDescriptor, SOL_SOCKET, SO_BROADCAST, (void*)&broadcastPermission, sizeof(broadcastPermission))
    

提交回复
热议问题