In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to achieve BroadCast in vxworks, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
With unicast and multicast, broadcasting can't run away. The difference between broadcast, BroadCast and unicast is that the address is different. The address for broadcasting is 255.255.255.255, and the broadcast data will not be forwarded by the router and is limited to the local area network, otherwise it will be a network storm.
The code for broadcasting is actually simpler. Refer directly to the example of unicast / multicast to write a
Server is slightly modified on the basis of unicast
Call socket () to open a Socket
Call bind () to specify Port information
Call setsockopt () to join the broadcast
Call recvfrom () to block reception
Finally, call close () to close Socket
It's easier to broadcast Client.
Call socket () to open a Socket
Specify broadcast address and Port information
Call sendto () to send data
Finally, call close () to close Socket
The complete code is as follows
# include / * pritnf () * / # include / * malloc () * / # include / * socket () * / # include / * struct sockaddr_in * /
# define HOST_PORT 60000#define MIN_SIZE 10#define MIN_TIMES 10
Void broadServer (int port, int size, int times) {struct sockaddr_in localAddr; struct sockaddr_in peerAddr; int addrSize = sizeof (struct sockaddr); int opt = 1; int fd; int num; char * buffer; if (port)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.