MultiCast Messages to multiple clients on the same machine

后端 未结 5 1832
醉话见心
醉话见心 2021-02-14 10:34

Im trying to write a server/service that broadcasts a message on the lan ever second or so, Kind of like a service discovery.

The message needs to be rece

5条回答
  •  一个人的身影
    2021-02-14 10:51

    I think you're looking for the SO_REUSEADDR socket option. Setting that option on a socket allows multiple sockets to listen on the same port. For multicast Windows guarantees that the message will be delivered to all sockets (otherwise the message only goes to one socket, randomly).

    You usually do this by calling setsockopt, but I'm not a Delphi developer so I'm not sure what your API looks like. This question seems to show an example of someone doing something similar in Delphi.

提交回复
热议问题