Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4083638
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:20:17+00:00 2026-05-20T18:20:17+00:00

We have a client and server application currently testing on the same Windows 7

  • 0

We have a client and server application currently testing on the same Windows 7 64 bit machine. They’re both written in C# and using P/Invoke to call out to the Winsock2 libraries.

The application works fine overall w/o any errors. And the latency for each “hop” over tcp/ip averages about 350 microseconds.

However, on occasion there are very long delays of upwards of 40 to 50ms before receiving packets and then suddenly they will all arrive.

Efforts to diagnose so far:

  1. During these delays receiving data, the server continues to log that it’s sending packets. It’s set to send test packets every 1 ms which it will do for 15 or 20 and as much as 50 ms sometimes before the client receives any of them.

  2. The tcpdump was used to sniff packets on the loopback adapter and shows that during this lag period, there’s traffic from the server port (6488) to the client port (61743) as usual.

  3. The client calls the select() winsock2 call in a loop so logging via a counter prior to the select() call shows that it has the correct file descriptor. And of course this works before and after the delay just fine.

  4. Further logging immediately after the select() call shows that the fd isn’t present–meaning that a read on the socket will block. However, during the periods of transmission w/o any delays, the logging shows it works as expected so that select() returns the fd of the socket to do a non-blocking read.

In short, the loopback adaptor seems to hold these packets somewhere for a long while before finally delivering them to the receiving side.

Any further ideas or a solution?

Some thoughts are the it’s often claimed that overlapped I/O works better on Windows but that seems to only matter for scalability if you need to listen to more than 64 sockets.

Can it be that switching to overlapped will do the trick? We want to avoid as that will increase the project deadline and budget. This should work with select() just fine.

Also, can it be that the process or thread in Windows that handles the loopback gets context switched or something and, if so, is there a way to configure it to avoid those delays?

Edit: The correct answer was to ensure that the Nagle algorithm was disabled. We thought it was disabled but that’s where the bug was found–in our in-house implementation of SetSocketOption() we used GetSocketOption() to verify. So it turns out you must set NoDelay prior to connecting or binding a socket or else it silently fails to have any effect.

Many thanks to Fun Mun Pieng for the correct answer!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:20:18+00:00Added an answer on May 20, 2026 at 6:20 pm

    I suspect this may be due to the Nagle algorithm. The following code disables it:

    socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a client-server application written in Java using CORBA for the communication. The
I am adapting a little rmi client-server application. I have written several things :
I have a client server based windows forms application that needs an administrator only
I'm running a client/server application locally on my Windows XP PC and for testing
I have a web application with a great deal of both client-side and server-side
We have a client/server application with a rich client front end (in .Net) and
I have a client/server application that communicates with .Net remoting. I need my clients
I have a client server application that sends XML over TCP/IP from client to
I have a client-server application that uses .net remoting. The clients are in a
I have a client/server application. One of the clients is a CLI. The CLI

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.