views:

49

answers:

1

Hello, I've a select based server. Sockets are in blocking mode,but for select() function I'm using 250 ms. timeout.

Basically my server accepts only one client and sending data to that client. It is working for weeks without problem if I just send data from server to client.

But I realized that if client sends data to server after 3-4 hours at the select() line it gives stack overflow exception (0xC00000FD). I red dozens of times MSDN page of Select(), but nothing mentioned related to this. I'm really stuck. Any help will be appreciated.

By the way, I found on the net, example;

http://tangentsoft.net/wskfaq/examples/basics/select-server.cpp

here after accepting client connection, he is setting it to nonblocking mode. And it is commented that;

 // Mark the socket as non-blocking, for safety.

What does "safety" means above? So do you think is this my problem? Because in my implementation, connected ones are in blocking mode?

Thanks in advance

+1  A: 

An exception means there is a bug in your code. Since you are getting a stack overflow, you likely have a recursive loop in your code that is running too long, eating up stack space on each call until there no more stack space left. Under normal conditions, select() returns an error code when it fails, so you have to be messing up your program's memory somewhere to be getting an exception.

Remy Lebeau - TeamB
Hi Remy, thanks for your reply. But the thing is that there is a loop which is polling with select() call. So there is no recursive function calls. And if client doesn't send any data there is exactly no problem. But if it sends data, after 4-5 hours it is giving buffer overflow at select() function. if it helps, I can post pseudo code?
AFgone
Then it is unlikely that you are getting a stack overflow. A buffer overflow is something completely different. It really does sound like you are mis-managing your code either way, though. So yes, please show some actual code.
Remy Lebeau - TeamB