Receive UDP Pockets

M

Mahesh

Hi am trying to receives UDP pockets , but it is blocking in the
"Socket.Receive" can any one help me to find the problem...?

byte[] buffer = new byte[50];
Socket socket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram,ProtocolType.Udp);
socket.Bind(new IPEndPoint(IPAddress.Any, 5703));
int byterx = socket.Receive(buffer, 0, 1, SocketFlags.None);
Console.WriteLine(byterx.ToString());
 
J

Jon Skeet [C# MVP]

Hi am trying to receives UDP pockets , but it is blocking in the
"Socket.Receive" can any one help me to find the problem...?

byte[] buffer = new byte[50];
Socket socket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram,ProtocolType.Udp);
socket.Bind(new IPEndPoint(IPAddress.Any, 5703));
int byterx = socket.Receive(buffer, 0, 1, SocketFlags.None);
Console.WriteLine(byterx.ToString());

Do you mean that it's blocking despite something sending a packet?
Socket.Receive is *meant* to block until it receives data.

Jon
 
M

Mahesh

Hi am trying to receives UDP pockets , but it is blocking in the
"Socket.Receive" can any one help me to find the problem...?
byte[] buffer = new byte[50];
Socket socket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram,ProtocolType.Udp);
socket.Bind(new IPEndPoint(IPAddress.Any, 5703));
int byterx = socket.Receive(buffer, 0, 1, SocketFlags.None);
Console.WriteLine(byterx.ToString());

Do you mean that it's blocking despite something sending a packet?
Socket.Receive is *meant* to block until it receives data.

Jon

jhon Socket.Receive is *meant* to block until it receives data ...but
am not able receive UDP packets ...can u check wats wrong in the code
or send me the code receive USP packets
 
J

Jon Skeet [C# MVP]

jhon Socket.Receive is *meant* to block until it receives data ...but
am not able receive UDP packets ...can u check wats wrong in the code
or send me the code receive USP packets

Well, you haven't shown the code you're using to *send* the UDP
packets.

Could you post two short but complete programs, one which receives and
one which sends, which combined demonstrate the problem?

See http://pobox.com/~skeet/csharp/complete.html for what I mean by
that.

Jon
 
M

Mahesh

Well, you haven't shown the code you're using to *send* the UDP
packets.

Could you post two short but complete programs, one which receives and
one which sends, which combined demonstrate the problem?

Seehttp://pobox.com/~skeet/csharp/complete.htmlfor what I mean by
that.

Jon

Thanks jon..but i don't have program to send UDP packets...actually am
trying to communicate with the RFID reader, reader will sends the UDP
packets properly..am able to see those packets in other network
tool..but am not able catch that using my program..
 
J

Jon Skeet [C# MVP]

Thanks jon..but i don't have program to send UDP packets...actually am
trying to communicate with the RFID reader, reader will sends the UDP
packets properly..am able to see those packets in other network
tool..but am not able catch that using my program..

It shouldn't be too hard to come up with a program to send packets
though, and then we'd all be able to reproduce it.

Jon
 

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