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 8336913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:08:15+00:00 2026-06-09T04:08:15+00:00

EDIT: Messed up my pseudo-coding of the accept call, it now reflects what I’m

  • 0

EDIT: Messed up my pseudo-coding of the accept call, it now reflects what I’m actually doing.

I’ve got two sockets going. I’m trying to use send/recv between the two. When the listening socket is blocking, it can see the connection and receive it. When it’s nonblocking, I put a busy wait in (just to debug this) and it times out, always with the error EWOULDBLOCK. Why would the listening socket not be able to see a connection that it could see when blocking?

The code is mostly separated in functions, but here’s some pseudo-code of what I’m doing.

int listener = -2;
int connector = -2;
int acceptedSocket = -2;

getaddrinfo(port 27015, AI_PASSIVE) results loop for listener socket
{
  if (listener socket() == 0)
  {
    if (listener bind() == 0)
      if (listener listen() == 0)
        break;
    listener close(); //if unsuccessful
  }
}
SetBlocking(listener, false);


getaddrinfo("localhost", port 27015) results loop for connector socket
{
  if (connector socket() == 0)
  {
    if (connector connect() == 0)
      break; //if connect successful
    connector close(); //if unsuccessful
  }
}

loop for 1 second
{
  acceptedSocket = listener accept();
  if (acceptedSocket > 0)
    break; //if successful
}

This just outputs a huge list errno of EWOULDBLOCK before ultimately ending the timeout loop. If I output the file descriptor for the accepted socket in each loop interation, it is never assigned a file descriptor.

The code for SetBlocking is as so:

int SetBlocking(int sockfd, bool blocking)
{
  int nonblock = !blocking;

  return ioctl(sockfd,
    FIONBIO,
    reinterpret_cast<int>(&nonblock));
}

If I use a blocking socket, either by calling SetBlocking(listener, true) or removing the SetBlocking() call altogether, the connection works no problem.

Also, note that this connection with the same implementation works in Windows, Linux, and Solaris.

  • 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-09T04:08:16+00:00Added an answer on June 9, 2026 at 4:08 am

    Because of the tight loop you are not letting the OS complete your request. That’s the difference between VxWorks and others – you basically preempt your kernel.

    Use select(2) or poll(2) to wait for the connection instead.

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

Sidebar

Related Questions

Edit: It turns out I missed something obvious, but I'm going to leave the
For some reason, my project has messed up and now its throwing errors every
I accidentally deleted my gen folder and now, predictably, my resources are all messed
I messed up on my SVN repository and now need to revert the entire
something messed up my mp3 and image library. Now, the files have correct modified
EDIT: I got some progress, so I have simplified and narrowed the problem: I
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
EDIT: I was an idiot. I simply had an image that was vertically long,
EDIT: See my answer below--> I am wanting to have a view that when
Edit (updated question) I have a simple C program: // it is not important

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.