By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,734 Members | 828 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,734 IT Pros & Developers. It's quick & easy.

UDPClient listen to any address, any port

P: n/a
In VB.NET 2003, is there a way to create a System.Net.Sockets.UDPClient
to listen to any address AND any port?

I can get it to listen to any address, but only if I specify a port (for
example, port 12345):

'-----------
Dim udpClient as New Sockets.UdpClient(12345)
Dim ipEndPoint as New IPEndPoint(IPAddress.Any, 0)
Dim receiveBytes as Byte()

receiveBytes = udpClient.Receive(ipEndPoint)
'-----------
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Use 0 (zero) as your port.
This way, all the ports will be listen to

Regards

Dieter Boden-Schelfthout

""D. André Dhondt"" <ky*****************@hotmail.com> schreef in bericht
news:u3****************@TK2MSFTNGP09.phx.gbl...
In VB.NET 2003, is there a way to create a System.Net.Sockets.UDPClient
to listen to any address AND any port?

I can get it to listen to any address, but only if I specify a port (for
example, port 12345):

'-----------
Dim udpClient as New Sockets.UdpClient(12345)
Dim ipEndPoint as New IPEndPoint(IPAddress.Any, 0)
Dim receiveBytes as Byte()

receiveBytes = udpClient.Receive(ipEndPoint)
'-----------

Nov 21 '05 #2

P: n/a
Dieter--zero doesn't get it to listen to all ports--even if I ctype it
as a short to get it to recognize it as a port in the first place:
Dim udpClient as New Sockets.UDPClient(CType(0,Short))

.... broadcasts to that udp client are not received. If I specify
another port, however, it can receive:
Dim udpClient as New Sockets.UDPClient(CType(12345,Short))

My broadcasting happens as follows:
Dim udpClient as New UDPClient
Dim ipEndPoint as New IPEndPoint(IpAddress.Broadcast, 12345)
Dim sendBytes as [Byte]() = Encoding.ASCII.GetBytes("Is anybody there?")
Dim sentBytes as Integer
sentBytes = udpClient.Send(sendBytes, sendBytes.Length, ipEndPoint)

Dieter Boden-Schelfthout wrote:
Use 0 (zero) as your port.
This way, all the ports will be listen to

Regards

Dieter Boden-Schelfthout

""D. André Dhondt"" <ky*****************@hotmail.com> schreef in bericht
news:u3****************@TK2MSFTNGP09.phx.gbl...
In VB.NET 2003, is there a way to create a System.Net.Sockets.UDPClient
to listen to any address AND any port?

I can get it to listen to any address, but only if I specify a port (for
example, port 12345):

'-----------
Dim udpClient as New Sockets.UdpClient(12345)
Dim ipEndPoint as New IPEndPoint(IPAddress.Any, 0)
Dim receiveBytes as Byte()

receiveBytes = udpClient.Receive(ipEndPoint)
'-----------


Nov 21 '05 #3

P: n/a
As I am coming to believe, UDPClient will listen to only one port for
the specified NIC--and as soon as my app binds to a port, the app has
exclusive use of the port until it releases it. Can anyone confirm or
refute this?

If the above is true, then I can't listen to all ports with one
UDPClient or even one socket.
D. André Dhondt wrote:
Dieter--zero doesn't get it to listen to all ports--even if I ctype it
as a short to get it to recognize it as a port in the first place:
Dim udpClient as New Sockets.UDPClient(CType(0,Short))

.... broadcasts to that udp client are not received. If I specify
another port, however, it can receive:
Dim udpClient as New Sockets.UDPClient(CType(12345,Short))

My broadcasting happens as follows:
Dim udpClient as New UDPClient
Dim ipEndPoint as New IPEndPoint(IpAddress.Broadcast, 12345)
Dim sendBytes as [Byte]() = Encoding.ASCII.GetBytes("Is anybody there?")
Dim sentBytes as Integer
sentBytes = udpClient.Send(sendBytes, sendBytes.Length, ipEndPoint)

Dieter Boden-Schelfthout wrote:
Use 0 (zero) as your port.
This way, all the ports will be listen to

Regards

Dieter Boden-Schelfthout

""D. André Dhondt"" <ky*****************@hotmail.com> schreef in
bericht news:u3****************@TK2MSFTNGP09.phx.gbl...
In VB.NET 2003, is there a way to create a System.Net.Sockets.UDPClient
to listen to any address AND any port?

I can get it to listen to any address, but only if I specify a port (for
example, port 12345):

'-----------
Dim udpClient as New Sockets.UdpClient(12345)
Dim ipEndPoint as New IPEndPoint(IPAddress.Any, 0)
Dim receiveBytes as Byte()

receiveBytes = udpClient.Receive(ipEndPoint)
'-----------


Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.