Windows socket programing

I am writing a client to receive packets from a server that a vendor wrote for an equipment.  For some reason I am not able to get anything back from the server.  I can send it stuff no problem, but I don't get a response back from it.

Client end provided by vendor:

int TCPClient::waitEvents(long millis) {
      timeval timeout;
      timeout.tv_sec = 0;
      timeout.tv_usec = millis*1000;
      fd_set      fd;
      FD_ZERO(&fd);
      FD_SET(socketHandle, &fd);
      sockaddr_in      from;
      int            len = sizeof(sockaddr_in);
                int         ret = 0;
      int num;
                int err=0;
      if ((num = select(NULL, &fd,NULL , NULL, &timeout)) > 0)  //<---right here I get a 0 returned by select and that's my problem.  In case of an error (socket error...etc) I should get a -1, but I get a zero.

"select" is defined by MS in winsock2.h as follows:

#if INCL_WINSOCK_API_PROTOTYPES
WINSOCK_API_LINKAGE
int
WSAAPI
select(
    int nfds,
    fd_set FAR * readfds,
    fd_set FAR * writefds,
    fd_set FAR *exceptfds,
    const struct timeval FAR * timeout
    );
#endif // INCL_WINSOCK_API_PROTOTYPES

What could my problem be?  Please help me I'm lost.
axnst2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rstaveleyCommented:
YOu need to set nfds
0
rstaveleyCommented:
Mind you, it says at http://msdn.microsoft.com/library/en-us/winsock/winsock/select_2.asp that you don't, because it is ignored. I hadn't readlised that.
0
rstaveleyCommented:
You're not just timing out are you?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

axnst2Author Commented:
What does nfds contain and what's a reasonable value for it?
0
axnst2Author Commented:
I might be..I am trying to communicate with it on a factory floor, wirless, 200 ft
0
axnst2Author Commented:
That was my guess too...I am setting up a laptop as we speek
0
rstaveleyCommented:
I usually do something like this:

       timeout.tv_sec = millis/1000;
       timeout.tv_usec = (millis%1000)*1000;

I've not seen if the timeout works with the timeout entirely in the microsecs part.
0
rstaveleyCommented:
nfds is conventionally the highest-numbered descriptor in any of the three descriptor sets plus 1; but the MS document says that it is being ignored.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
grg99Commented:
How long are you waiting?   i.e. what is millis?

also be sure you're not overflowing the integer arithmetic, or the size of usec.
A few simple if() statements as suspenders wouldnt hurt.

In my experience the debugging of these kinds of problems goes about a bazillion times faster if you have some sort of network sniffer.  Many times a peek at a packet immediately shows the problem, where otherwise I would have flailed around for weeks trying various things.

There are several nice free sniffers for Windows and Linux, I strongly  suggest you get one of these.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.