Pergunta

I need each computer running my program to send out their IP over and over to the multicast, and I need each computer running to be able to build a list of available hosts running the program. Is there any way to do this with UDP in C#?

Foi útil?

Solução

What you want is broadcast NOT multicast. Yes this is possible, you need to:

  • Send data to a broadcast address, e.g. 192.168.255.255 on the port no. your hosts are running on. This will send the data to everyone connected to the 192.168.x.x subnet. (255.255.255.255 is valid - to send to everyone - but that is almost always dropped and probably will not work).
  • You do not need to include your IP in the broadcast because the recipient can see the IP end point they received the data from.

NOTE: Firewall's, NAT and the like will usually drop incoming unsolicited data unless specifically told to allow/forward it. On LANs what is described above usually works without changes.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top