Passive bind/listen for UDPClient?

G

gregory_may

I want to bind multiple UDPClients to the same port on the same machine. I
want them to all listen for broadcast messages & respond accordingly.

Multiple client bindings "under normal circumstances" doesn't work (That's
the error I am getting).

But, it seems very reasonable to set up many UDPclients to receive the same
broadcast messages off the same port on the same machine.

Is there some way to passively bind multiple UDPclients to the same port on
the same machine?

Is there some lower level socket class I can use to catch these messages?

In general, this is my current approach:

http://www.ondotnet.com/pub/a/dotnet/2003/04/14/clientserver.html?page=last


Named pipes would probably be a perfect fit for this, but I haven't seen any
good approaches for named pipes that are as lean as UDP.
 
G

gregory_may

Ok, I got it.

I cant seem to get the UDPClient class to do this directly, so this seems to
be working:
udpClient = New Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp)
Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, MyListenPort)
Dim myGroup As IPAddress
myGroup = IPAddress.Parse(MyListenIP)

'Reusing the address should let multiple clients listen to the same Port
udpClient.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReuseAddress, 1)
udpClient.Bind(RemoteIpEndPoint)
udpClient.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.AddMembership, New MulticastOption(myGroup, IPAddress.Any))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top