Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Accurate UDP connection

Accurate UDP connection

Scheduled Pinned Locked Moved C#
csharptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Berlus
    wrote on last edited by
    #1

    Hello, I'm trying to read messages from an outside source that orks on 30HZ (every 33 msec there is a new message). I tried to use the udp classes in .Net but I discovered that althogh 80% of the time the messages reciveing interval is about 33 msec, sometimes i get picks of 50 and more. 1. How would you solve it ? 2. Is it beacuse it is a UDP connection ? 3. Can I recieve in a diffrent way (using dllimport to some udp recieving dll for example ?). thanks,

    M 1 Reply Last reply
    0
    • B Berlus

      Hello, I'm trying to read messages from an outside source that orks on 30HZ (every 33 msec there is a new message). I tried to use the udp classes in .Net but I discovered that althogh 80% of the time the messages reciveing interval is about 33 msec, sometimes i get picks of 50 and more. 1. How would you solve it ? 2. Is it beacuse it is a UDP connection ? 3. Can I recieve in a diffrent way (using dllimport to some udp recieving dll for example ?). thanks,

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      You're using an inaccurate clock. The Windows tick timer (Environment.TickCount) ticks at a frequency of around 15-16ms, so you will normally see durations measured with this timer as being some multiple of 16ms. Try using the Stopwatch class instead, if using .NET 2.0 or later. That said, UDP is always susceptible to network delays. Routers can delay or drop packets if a link is saturated. LANs will drop packets and have to retransmit if two stations try to send at the same time (this is referred to as a collision). You would need a dedicated link to avoid the possibility of a collision.

      DoEvents: Generating unexpected recursion since 1991

      B 1 Reply Last reply
      0
      • M Mike Dimmick

        You're using an inaccurate clock. The Windows tick timer (Environment.TickCount) ticks at a frequency of around 15-16ms, so you will normally see durations measured with this timer as being some multiple of 16ms. Try using the Stopwatch class instead, if using .NET 2.0 or later. That said, UDP is always susceptible to network delays. Routers can delay or drop packets if a link is saturated. LANs will drop packets and have to retransmit if two stations try to send at the same time (this is referred to as a collision). You would need a dedicated link to avoid the possibility of a collision.

        DoEvents: Generating unexpected recursion since 1991

        B Offline
        B Offline
        Berlus
        wrote on last edited by
        #3

        nope, i'm using the multimedia timer, which is just as accurate as the Stopwatch.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups