Setting an IP for UDPsocket

On a computer with VMplayer installed the computer has two(or more) IP addresses ie and
The second one is a VMware network adapter.
if I run

  For i As Integer = 0 To System.NetworkInterfaceCount-1
    AddtoDebugFile("   MAC "+n.MACAddress+" IP  "+n.IPAddress+" Subnet mask "+n.SubnetMask)

this will get a list of all the network interfaces and using the above code returns

MAC 00:21:6A:93:50:3B IP Subnet mask
MAC 00:21:6A:93:50:3A IP Subnet mask
MAC 00:26:B9:13:B8:D4 IP Subnet mask
MAC 00:50:56:C0:00:01 IP Subnet mask
MAC 00:50:56:C0:00:08 IP Subnet mask

I have a UDPsocket on the main window, and its IP is

So it seems to pick the last IP.
Is there anyway to force the UDPsocket to use one of the other IP addresses? in this case I want to use

You don’t need to. You specify the address when you Write to the socket.

Hi Tim, Thanks. I’m setting up a messaging system for small networks . If all the other computers are in the 10.0.0.(1-255) range and my computer is I get problems with broadcast messages I think. If a 10.0.0.x computer sends out a broadcast to port 10125 all the other computers in the 10.0.0.x range will get it if they are listening,but the wont (may depend on the router)?)
Anyway, I think I have sorted it.


this code will select the second address. So I can force the computer to use the IP I want.
Its sort of an edge case as most computers dont have VMware and this problem, but some do…

Thanks for your fast reply, I’m always amazed I get such fast replies on here.