Receive UDP Pockets

  • Thread starter Thread starter Mahesh
  • Start date Start date
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());
 
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
 
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
 
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
 
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..
 
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
 
Back
Top