Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


select giving me a WSAEINVAL error...

This topic is 5398 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am getting a WSAEINVAL error from the "select()" function. the documentation says this error means "The timeout value is not valid, or all three descriptor parameters were NULL." i am quite certain that all three descriptor parameters are not NULL (and yes, i do rebuild them each time), nor is the timeout value invalid (it is set to {0,0} for polling, as per the documentation, and i even tried to replace it with NULL (blocking) just to see if it worked). strangely enough, it works in another program i wrote a while back, which i re-compiled just to make sure this is very frustrating, can anyone think of something that might be wrong? here is the relevant code:
  timeval timeout;
  fd_set input_set, exc_set;
  int s, nfds;
  nfds = 0;
  timeout.tv_sec = 0;
  timeout.tv_usec = 0;
  for(int i = 0; i < MAX_CLIENTS; ++nfds, ++i)
      FD_SET(p_clients[i].getSocket(), &input_set);
      FD_SET(p_clients[i].getSocket(), &exc_set);
  s = select(nfds, &input_set, 0, &exc_set, &timeout);
p_clients is an array of my "client connection class", which basically holds a SOCKET and a status (checkStatus(CSTATUS_ACTIVE) returns true if there is an open socket there). at the point directly after the last line above, s == SOCKET_ERROR, and WSAGetLastError() returns the WSAEINVAL. thanks in advance!

Share this post

Link to post
Share on other sites
ok, after some more testing, i discovered that i only get this error when there is nobody connected (i.e. the "input_set" and "exc_set" are empty). once there is even a single socket in the list i do not get the error. i suppose i could ignore the error if there is nobody connected at all (in fact, i might as well skip the "select" altogether), but it still bugs me that this error occurs when it shouldn''t (i.e. none of the parameters are invalid, they''re just empty).

strangely enough, the older program i mentioned still works fine when nobody is connected.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!