Click to See Complete Forum and Search --> : IOCP WSASend and timeout


Naumaan
June 3rd, 2004, 07:16 AM
HI

I m developing a small application using IOCompletion Port
every thing is working fine but if i m sending messages with WSASend function and Client is not receiving due to machine load,hang or extra load then what will be the behaviour of WSASend. Because when we post WSASend and it returns WSA_IO_PENDING then it means our message is posted successfully and we will be notifyed when send is complete by GetQueuedCompletionStatus.

So my problem is that when i send lot of messages and receiving end did not receive message then my computer's Non paged memory increses and after some time my machiene show abnormal behaviour.


I just want to know that how can i adjust sending message timeout .Because if receiving end did not receive a message within that time period then i will stop to send further messages or do some appropriate action .

I have seen setsockoption with SO_SNDTIMEO but it did not solve my problem.

Please help me .

thanks in advance

Andreas Masur
June 6th, 2004, 06:28 AM
[Moved thread]

kuphryn
June 6th, 2004, 10:01 AM
One solution is to stop sending messages if a fixed number of messages are still in a pending state.

Kuphryn

Mathew Joy
June 8th, 2004, 01:24 AM
SO_SNDTIMEO won't work in your case because that option is for blocking calls and you are using non-blocking calls.

The other options are to use CancelIo() or to close the socket and I reckon that cannot be fit into your case.

So the other option is to limit the no of IOs. A good server should always monitor the resource it is using and limit the IOs accordingly so that your server won't run into some low-resource condition and just die. Your server should have the number of outstanding IOs and see that it does not exceed the limit. The best way to get this limit is to simulate load conditions to arrive at a limit. NP memory grows almost upto 1/4th of the total physical RAM. You may either get a WSAENOBUFS error or get into some other driver problem ending up crashing your server. So if you know that your server may run into conditions where it may encounter low-resource state, you must monitor the outstanding IOs and take actions accordingly.

Hope you are clear.

:thumb:

Naumaan
June 30th, 2004, 08:43 AM
Sorry for late reply

Is there any way to detect how many outstanding IOs are with a particular socket in IOCP model.

Thanks in advance

Mathew Joy
June 30th, 2004, 09:23 AM
No, you have to do that manually. Increase a counter for each overlapped issue and decrease them for each ios that is satisfied. It is good for the server to have a first hand info of how many outstanding recv/send, connected sockets total o/s overlapped calls etc.