473,715 Members | 5,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Socket and UdpClient when App is used under NT.

Hi,

I've developed an application in C# which spawns a thread
to receive datagrams.

If I use the socket receive method, there are no problems
when using the application under NT or XP.

I recently moved over to using the UdpClient receive
method. This was so I could record the IPEndPoint from
the datagram received to determine the IP address of the
sender. Problem is, the UdpClient method seems to have
problems keeping up with the incoming datagram rate under
NT. This problem does not occur when using XP.

I could use the Socket receive from method as a work
around, but this uses an EndPoint and not an IPEndPoint
making the IP address of the sender impossilble to extract?

I am puzzled to why the UdpClient works differently under
NT?

Richy.

Nov 15 '05 #1
2 1820
"Richy Rich" <ri************ *@yahoo.co.uk> wrote in message news:<05******* *************** ******@phx.gbl> ...
Hi,

I've developed an application in C# which spawns a thread
to receive datagrams.

If I use the socket receive method, there are no problems
when using the application under NT or XP.

I recently moved over to using the UdpClient receive
method. This was so I could record the IPEndPoint from
the datagram received to determine the IP address of the
sender. Problem is, the UdpClient method seems to have
problems keeping up with the incoming datagram rate under
NT. This problem does not occur when using XP.

I could use the Socket receive from method as a work
around, but this uses an EndPoint and not an IPEndPoint
making the IP address of the sender impossilble to extract?

I am puzzled to why the UdpClient works differently under
NT?

Richy -

You can still use the IPEndPoint class with the ReceiveFrom()
method, just typecast the results:

recv = sock.ReceiveFro m(ref ep);
IPEndPoint iep = (IPEndPoint)ep;
Console.WriteLi ne("Packet received from host {0}, port {1}",
iep.Address, iep.Port);

As to the performance hit, there is a lot happening under the hood
of the UdpClient class. Perhaps your two systems are powered
differently enough that the "under-the-hood" work is noticeable. I
prefer to do my coding using the Socket class because it is more
versatile, and is easier for me coming from a Unix socket background.
That said, I still think the TcpClient and UdpClient classes are great
for programmers who don't need fancy functionality (and possibly
performance?) from their network code.

Hope this helps shed some light on your problem.

Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyT...471433012.html
Nov 15 '05 #2

thanks for your help.

i'll give that a try.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3

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

Similar topics

4
41895
by: Stephan Steiner | last post by:
Hi I have a networking application that periodically needs to go into sleep mode (from an application point of view, I'm simply suspending the receiver thread until it's time to start listening to incoming packets again). The packets I'm interested in are UDP broadcasts, so they are simply dropped when nobody application is listening at the specified port. However, when I initialize my receiver, there's a socket listening at the...
0
11860
by: Stephan Steiner | last post by:
Hi The project I'm currently working on involves sending large UDP broadcasts. As the .NET framework already provides an easy facility for sending and receiving UDP packets I thought it was a good idea to use UdpClient rather than sockets directly. A few weeks back I ended up rewriting the receiver part to use sockets directly because I had to manipulate some low level socket properties, and those manipulations would fail on the...
6
4123
by: roger beniot | last post by:
I have a program that launches multiple threads with a ThreadStart method like the following (using System.Net.Sockets.Socket for UDP packet transfers to a server): ThreadStart pseudo code: Connect Receive response Send Connect ACK
5
11694
by: Terry | last post by:
It's my understanding of UDP sockets that if there is a thread blocked on a "recvFrom()" call and other thread sends a UDP packet to some address, that if the machine on the other end isn't up, that the "recvFrom()" call should just continue blocking. Right? What I'm seeing is that when I send a packet to a particular address that is not responding, my "recvFrom()" call throws an exception. I get "An existing connection was forcibly...
1
3969
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 the UdpClient class to receive, it never works. The messages are never received (no exceptions). If I use a normal socket configured to listen for Udp messages, it works perfectly. Below is my sample code. It is only test code - I know the...
2
7291
by: chewie | last post by:
I'm in the process of creating a multicast application but I'm having difficulty getting the UDPClient to work. The UDPClient works on my local machine only, not across the network. I've been able to get the multicast message to work across a network by creating a socket, but I can't get it to work via UDPClient. What is the difference between the two? Why does the socket method work and not the UDPClient? Thanks ...
2
2878
by: Rene Sørensen | last post by:
We are 4 students working on a assignment, that our teacher gave use, normally we do this is C++, but the 4 of us, use C# more often that C++ so… We made a small games called reversi, now our job is to make a server, none of us know nothing about socket programming in C#, but we founds some guides for this, and now ,got a server running, but we have some problems though. We have 2 scenario, one where we use a telnet connection and one...
0
366
by: Jarod_24 | last post by:
Background: Im working on a remote console (rcon) for accessing dedicated quake3 servers. Quake 3 uses UDP and Out Of Bands packets to communicate in ASCII text (see more here http://web.archive.org/web/20010802142555/http://www.quake3arena.com/tech/ServerCommandsHowto.html) I used the UDPClient.Send() and Recive() to test this and it worked quite well, except for that since i dont know how many packets the server will send in response...
0
1069
by: Ron L | last post by:
I am trying to write a program that will open a UDPClient and listen on it. I have based my code on the example at MS in the "UDPClient.Receive Method (.NET Framework)" file, but when I try to call the .Receive method I get the following exception: System.Net.Sockets.SocketException: An invalid argument was supplied at System.Net.Sockets.Socket.ReceiveFrom(Byte buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint&...
0
8718
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9343
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
9198
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...
0
9047
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...
0
7973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5967
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
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3175
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.