Socket and UdpClient when App is used under NT.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richy Rich

    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.



  • Rich Blum

    #2
    Re: Socket and UdpClient when App is used under NT.

    "Richy Rich" <richyrich_n200 2@yahoo.co.uk> wrote in message news:<056601c37 e9b$fcfcea50$a0 01280a@phx.gbl> ...[color=blue]
    > 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?
    >[/color]
    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)

    "Network Performance Open Source Toolkit" (Wiley)

    Comment

    • Richy Rich

      #3
      Re: Socket and UdpClient when App is used under NT.


      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!

      Comment

      Working...