473,320 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

UDPClient doesn't receive any data

What I'm trying to do seems pretty simple on the face of it -- create a
UDP listener on a particular port. My code is as follows:

int port = 9000;
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, port);
UdpClient listener = new UdpClient(endPoint); // or new
UdpClient(port);

while (true){
byte[] bytes = listener.Receive(ref endPoint);
...
}

Unfortunately, my code never gets past the receive statement. I know
the data is coming into the machine, and a Java version of the same
code works just fine with the same server side resources.

What am I doing wrong here? I've looked at several past threads on the
same topic area and tried each and every suggestion, to no avail.

Help!

Thanks

Sandeep

Aug 30 '06 #1
2 2870
ss*******@yahoo.com wrote:
What I'm trying to do seems pretty simple on the face of it -- create a
UDP listener on a particular port. My code is as follows:

int port = 9000;
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, port);
UdpClient listener = new UdpClient(endPoint); // or new
UdpClient(port);

while (true){
byte[] bytes = listener.Receive(ref endPoint);
...
}
Try:

int port = 9000;
UdpClient listener = new UdpClient(port);
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 0);
while (true){
byte[] bytes = listener.Receive(ref endPoint);
...
}

Arne

Aug 30 '06 #2
Thanks for the suggestion, this seems to work!

Sandeep

Arne Vajhøj wrote:
ss*******@yahoo.com wrote:
What I'm trying to do seems pretty simple on the face of it -- create a
UDP listener on a particular port. My code is as follows:

int port = 9000;
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, port);
UdpClient listener = new UdpClient(endPoint); // or new
UdpClient(port);

while (true){
byte[] bytes = listener.Receive(ref endPoint);
...
}

Try:

int port = 9000;
UdpClient listener = new UdpClient(port);
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 0);
while (true){
byte[] bytes = listener.Receive(ref endPoint);
...
}

Arne
Aug 30 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Morten Overgaard | last post by:
Hi I'm listening on the SysLog port (514) through UDP. The problem is that I am not receiving anything nut I know that i get messages on the port. When I use KIWI to listen on the same port via...
4
by: Emilio | last post by:
In the help pages for the UdpClient there is some sample code which sends a udp message and prints what it received. Can someone help me to finish the code present there? I think basically the...
1
by: Dan Kelley | last post by:
I have 2 projects - 1 Winform project that sends Udp messages using the UdpClient class when a button is clicked, and a Console application that listens for these Udp messages. If I try to use...
2
by: Rick | last post by:
Hi, I'm trying to get a simple UdpClient app working. I've been looking at the MSDN info regarding UdpClient. When I set it up on my own PC and send messages to myself it works OK. If I try to...
2
by: Emilio | last post by:
Question about UdpClient sample ' This constructor arbitrarily assigns the local port number. Dim udpClient As New UdpClient() Try udpClient.Connect("www.contoso.com", 11000) ' Sends a...
1
by: Plem | last post by:
Hi All, I've allready posted this on the C# group (oops). I'm trying to get a UDPclient to receive. I use the sample code provided in HELP but to nbo avail. When the receive method is...
3
by: D. André Dhondt | last post by:
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,...
7
by: | last post by:
I have the following program using System; using System.Collections; using System.Net.Sockets; using System.Net; using System.IO; public class Test { public static void Main(string s) {
0
by: Johan | last post by:
Suppose: There are two devices on my network that both broadcast UDP datagrams (and they both use the same portnumber 1234). I want to create two executables that use UdpClient internally. Each...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.