0

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

Toby
  • 9,696
  • 16
  • 68
  • 132
  • To clarify most of the text of this question is intended to better describe where I am at in my learning curve and why I am attempting to do what I ask, as I dont even know yet if this is the correct way of going about things! My actual question is how to set a UDP connection to use a specific network interface as the local end of a connection instead of other enabled interfaces – Toby Jul 02 '13 at 15:55

2 Answers2

1

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.

Community
  • 1
  • 1
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
  • well OK my main question was how to select a specific network interface for the local end of a udpclient connection. Will take a look at your link also though. – Toby Jul 02 '13 at 15:38
  • this does help, somewha, with the receiving, but has nothing on the setting of network interface to use. – Toby Jul 02 '13 at 15:54
0

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.

Toby
  • 9,696
  • 16
  • 68
  • 132