Pergunta

I am starting out with network programming and networks in general, struggling quite a bit. I would like to make a UDP connection (socket or client) from the ethernet connection on my PC, i.e. NOT the wireless - which goes to the router to the internet.

I would like to send out a message to all devices that might be listening on the network connected at the ethernet network interface and then listen for any answers. I did see multicast mentioned for selecting a specific interface, but dont understand how to use it...

Furthermore, looking at the udpClient I'm not sure how I should listen, or recieve, any responses

Foi útil?

Solução 2

So apparently I needed to create a UDP socket independent of any client, bind it to the local interface (using bind()) and then set a client to use that socket.

I haven't figured out how to actually do the last bit though (i.e. set a client to use an already created socket) as I was working from a C# example which used syntax that obv wasn't valid in my vb to do this.

Outras dicas

This question is really too broad to be answered.

When sending data like this the framework will pick the appropriate network interface based on the IP you give it. The accepted answer to this question shows how you can broadcast to all interfaces.

But to get you started try this example project:

http://www.codeproject.com/Articles/8877/UDP-Send-and-Receive-using-threads-in-VB-NET

That should cover everything you asked about. If you have more specific questions once you look into the source then post another question.

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