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

  • SEARCH
  • Home
  • 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 8773651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:21:16+00:00 2026-06-13T18:21:16+00:00

I’m working to port some relatively simple network code from unix to Windows. In

  • 0

I’m working to port some relatively simple network code from unix to Windows.

In brief, there’s a single network thread which manages all network traffic. This single thread sits inside poll() most of the time (I’ve already converted this to select(), on Windows), the network thread only waking up when there’s incoming network data. When a client command arrives, the network thread fires the command off to a worker thread to actually perform work on the back-end, and then goes back to listening for more incoming commands. Commands are asynchronous — multiple commands can come in on one socket, one right after the next. At any one time, there can be dozens of outstanding commands on a single connection, all being worked on in various worker threads.

The problem is that when the worker thread wants to send response data, the network thread is probably asleep inside poll() at the time that the worker thread is trying to send its result. The network thread has to wait for poll() to time out (or another packet to be received) before it will notice that there’s new outbound data queued up to be sent.

Under unix, I deal with this by including a pipe amongst the descriptors being watched by poll(), and when a worker thread has outbound data to send, it also writes a byte of data into the pipe to wake up the network thread. But WinSock only seems to support waiting on sockets, so that approach isn’t going to work for me in Windows. Is there any way for me to salvage this architecture on Windows using WinSock (so I can share most of the code between different platforms), or is there no option but to write a custom network server implementation for use on Windows?

Thanks for any advice!

  • 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-06-13T18:21:17+00:00Added an answer on June 13, 2026 at 6:21 pm

    There can only be two possibilities, and neither requires the solution you are proposing:

    1) You are already trying to send data on this connection and the OS’s send queue is full. In this case, there is no need to abort out of select or poll. You can’t write on the connection right now anyway, and you’ll exit select or poll automatically as soon as you can.

    2) You are not currently trying to send data on this connection. In this case, there is also no need to abort out of select or poll. Just write the data right now in the worker thread. (The socket is non-blocking, right?) If you don’t write all of the data, it would only be because the OS’s send queue is full, in which case there’s usually no rush to write (set a reasonable timeout on the select call).

    You really shouldn’t use select on Windows though. It’s an abomination offered only as a gross hack for compatibility. If you plan on “really” supporting Windows, you shouldn’t make it second class. Network I/O is something that really has to be platform-specific.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I know there's a lot of other questions out there that deal with this

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.