473,320 Members | 1,848 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.

Thread.uSleep

Hi,
I have a problem coding a UDP Server/client. The server needs to send big
amounts of data over UDP. The problem however is that you can't send as fast
as you like. (All packets will be dropped due to the fact that a router
can't handle the huge number of packets (most likely the first one the
packets hit)).

To fix this problem you need to increase/decrease the speed according to
packetloss.

The problem I'm facing at the moment is; When I need to wait less then 1 ms
in between sending 2 packets. At the moment I'm using Thread.Sleep to time
the packets. Which is working quite nicely won't go faster then ~1.4
mBytes/s depending on packet size while testing.

Is there a simple way to fix this without using a busy waiting or do I need
to use p/invoke (To get to usleep or something).
(you can't resolve this by changing packet size due to the fact that most
routers have a max MTU length!)

Thanks, Matthijs
Nov 17 '05 #1
1 5183

"Matthijs" <Re.AL@no°spam.hccnet.nl> wrote in message
news:a4***************************@news.chello.nl. ..
Hi,
I have a problem coding a UDP Server/client. The server needs to send big
amounts of data over UDP. The problem however is that you can't send as
fast as you like. (All packets will be dropped due to the fact that a
router can't handle the huge number of packets (most likely the first one
the packets hit)).

To fix this problem you need to increase/decrease the speed according to
packetloss.

The problem I'm facing at the moment is; When I need to wait less then 1
ms in between sending 2 packets. At the moment I'm using Thread.Sleep to
time the packets. Which is working quite nicely won't go faster then ~1.4
mBytes/s depending on packet size while testing.

Is there a simple way to fix this without using a busy waiting or do I
need to use p/invoke (To get to usleep or something).
(you can't resolve this by changing packet size due to the fact that most
routers have a max MTU length!)

Thanks, Matthijs


Beware that Thread.Sleep(n), sets the calling thread to sleep for at least n
milliseconds, if n < one clock period, the thread will put asleep for at
most one clock period.
For most modern X86 based systems, the clock period is set to 10msec., but
periods of 15.6msec or higher are also possible (like on AMD and SMP boxes).
That means that when you call Sleep(1) on a system with a 10msec. clock
period, this will put the thread to sleep for at least 0 millisecond up to
10 msec, the same, if you call Sleep(9), your thread might sleep from 0 up
to 10 msec. That means that calling Sleep(n) with n lower than the clock
period tends to be very inaccurate and in general makes no sense at all.
Willy.

Nov 17 '05 #2

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

Similar topics

14
by: adeger | last post by:
Having trouble with my first forays into threads. Basically, the threads don't seem to be working in parallel (or you might say are blocking). I've boiled my problems to the following short code...
4
by: Gilles Leblanc | last post by:
Hi I have started a small project with PyOpenGL. I am wondering what are the options for a GUI. So far I checked PyUI but it has some problems with 3d rendering outside the Windows platform. I...
7
by: Ivan | last post by:
Hi I have following problem: I'm creating two threads who are performing some tasks. When one thread finished I would like to restart her again (e.g. new job). Following example demonstrates...
4
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the...
5
by: Razzie | last post by:
Hi all, A question from someone on a website got me thinking about this, and I wondered if anyone could explain this. A System.Threading.Timer object is garbage collected if it has no...
16
by: droopytoon | last post by:
Hi, I start a new thread (previous one was "thread timing") because I have isolated my problem. It has nothing to do with calling unmanaged C++ code (I removed it in a test application). I...
9
by: mareal | last post by:
I have noticed how the thread I created just stops running. I have added several exceptions to the thread System.Threading.SynchronizationLockException System.Threading.ThreadAbortException...
13
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow...
0
by: jeet232 | last post by:
hi, i need to know that how to pause a thread for a specific time in linux. i'm using usleep but its not accurate enough. any other? thanks
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.