when I use a display product,it use a programe to find and setup the product in a local network,it is very useful for use.
so I ask how to realize it . they told me use broadcast and http.
Broadcast can use in local network, to find what you want.Broadcast use UDP protocal .
In a network,product bind a port to UDP for ser,then we run a client,send msg to port to broadcast ip,then product can recv msg
then tell cli,so cli can find thost product.
In my company,I use 192.168.0.255 to be the broadcoast ip.
client code: 1)socket SOCK_DGRAM use UDP protocal
2)setsockopt SOL_SOCKET SO_BROADCAST to send broadcast msg
ser code: 1)socket SOCK_DGRAM use UDP protocal
2)bind port INADDR_ANY
阅读(263) | 评论(0) | 转发(0) |