473,788 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Receive UDP Pockets

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(AddressF amily.InterNetw ork,
SocketType.Dgra m,ProtocolType. Udp);
socket.Bind(new IPEndPoint(IPAd dress.Any, 5703));
int byterx = socket.Receive( buffer, 0, 1, SocketFlags.Non e);
Console.WriteLi ne(byterx.ToStr ing());

Jun 22 '07 #1
5 7421
On Jun 22, 11:23 am, Mahesh <calltomah...@g mail.comwrote:
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(AddressF amily.InterNetw ork,
SocketType.Dgra m,ProtocolType. Udp);
socket.Bind(new IPEndPoint(IPAd dress.Any, 5703));
int byterx = socket.Receive( buffer, 0, 1, SocketFlags.Non e);
Console.WriteLi ne(byterx.ToStr ing());
Do you mean that it's blocking despite something sending a packet?
Socket.Receive is *meant* to block until it receives data.

Jon

Jun 22 '07 #2
On Jun 22, 3:43 pm, "Jon Skeet [C# MVP]" <s...@pobox.com wrote:
On Jun 22, 11:23 am, Mahesh <calltomah...@g mail.comwrote:
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(AddressF amily.InterNetw ork,
SocketType.Dgra m,ProtocolType. Udp);
socket.Bind(new IPEndPoint(IPAd dress.Any, 5703));
int byterx = socket.Receive( buffer, 0, 1, SocketFlags.Non e);
Console.WriteLi ne(byterx.ToStr ing());

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

Jun 22 '07 #3
On Jun 22, 11:53 am, Mahesh <calltomah...@g mail.comwrote:
Do you mean that it's blocking despite something sending a packet?
Socket.Receive is *meant* to block until it receives data.

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

Jun 22 '07 #4
On Jun 22, 3:57 pm, "Jon Skeet [C# MVP]" <s...@pobox.com wrote:
On Jun 22, 11:53 am, Mahesh <calltomah...@g mail.comwrote:
Do you mean that it's blocking despite something sending a packet?
Socket.Receive is *meant* to block until it receives data.
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?

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

Jon
Thanks jon..but i don't have program to send UDP packets...actua lly 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..

Jun 22 '07 #5
On Jun 22, 12:02 pm, Mahesh <calltomah...@g mail.comwrote:
Thanks jon..but i don't have program to send UDP packets...actua lly 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

Jun 22 '07 #6

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

Similar topics

4
16050
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 UDP tons of messages arrive.. What am I'm doing wrong My code looks like the following... private UdpClient udpClient;
1
5373
by: Kitchen Bin | last post by:
Hi. I am trying to use Sockets to do multiple Send and Receives via HTTP (not simultaneously). A first pair of Send/Receives works fine and sure enough I receive HTML back, but the next Send/Receive pair (even if identically the same as the first pair) returns no data. eg. The following simplified code will receive some bytes: s.Send(ByteGet, ByteGet.Length, SocketFlags.None); bytes = s.Receive(RecvBytes, RecvBytes.Length, 0); //...
2
12680
by: Bruce Vander Werf | last post by:
How can I cleanly stop a thread that is currently blocking on Socket.Receive? I don't want to use Thread.Abort, because I would like the thread method to exit cleanly, and the same code must run under the Compact Framework, which does not support Abort. Will Socket.Close cause the Receive method to finish, or is there a better way?
6
6509
by: PHLICS_Admin | last post by:
Hi All, There are two network cards in one computer (named A) , and there is one network card in another computer(named B). On computer A: one network card is used to connect to internet, and the other network card is used in intranet whose ipaddress is 192.168.0.1 On computer B: the network card's ipaddress is 192.168.0.2. These two computer can connect to each other.
1
3849
by: Saso Zagoranski | last post by:
Hi! I have simple client/server game that uses sockets to transfer different messages. The server and the client are running on the same machine.
0
2060
by: Shoveler | last post by:
I've got an odd problem here that I've been beating my head on for days. I've written a class that uses a pre-established connection for communication, meaning I can use this class for a server or a client. After receiving a Socket that has been connected to a RemoteEP, it begins 2 threads by calling out Begin(). My Send Thread pauses until the class Parent wants to send data. Receive Thread keeps checking for incoming data. My...
2
4358
by: iwasinnihon | last post by:
I am writing a simple program to receive over http using windows sockets. my program does fine receiving text files. But returns the incorrect data when receiving image files. (The size of the files are different). My code is below. The header has already been read using the same Receive() function. What have I done wrong. ofstream os("file.dat", ios::binary); //Retrieve the body try {
3
3617
by: Joe Blauth | last post by:
Hi all, I am currently working on a small application that sends messages from a client to a server and receives messages in return. Basically the functionality is made with sockets which is working just fine except of one little thing. whenever the client tries to receive a message the server has sent it goes into a hang. unfortunately without an error or exception at all. the communication itself (sending message from client to...
0
1573
by: =?Utf-8?B?UmFqbmk=?= | last post by:
Dear William Stacey, I have written a server code using the Windows Socket API's. Wherein I have created the socket and bound it to a particular IP address and port number. Later I have made the socket in non-blocking mode by using the proper socket option ( i.e. SO_RCVTIMEO). After which with the use of recv() I am trying to get into the receive mode. Here as the receive time out is being used the socket should come out of the block...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10370
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10113
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2896
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.