Re: Recv timeout notification from a non-blocking socket using IOCP?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



You can use select() which do have TO or set timer independantly
Arkady

"BCatlin" <BCatlin@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2F620CA0-8C38-4EAA-9A87-6D6D87214E9E@xxxxxxxxxxxxxxxx
>I have a server that uses IO completion ports for socket event
>notification.
> I've got a set of threads hanging off a port and a bunch of accepted
> worker
> sockets that have been handed to the OS. I want to be able to call
> setsockopt to set SO_RCVTIMEO to 60000 (60 seconds) so that if the socket
> does not receive data within that time after being accepted then I can get
> notified (and in this case close the socket).
>
> Apparently SO_RCVTIMEO is not supported for non-blocking sockets, as per
> the
> MSDN API docs. But the docs don't indicate what IS supported. Yes, I can
> keep track of the connected sockets elsewhere and disconnect them if they
> hang around too long, but that seems like a hack to me. I would think
> that
> there is a way to tell the OS that I want to be notified when this
> happens.
>
> I have tried setting the option anyway (even though the docs say it won't
> work), and it doesn't work. I'm using GetQueuedCompletionStatus to read
> from
> the IOCP. I get notified of the accept event and I call WSARecv. I then
> get
> no more notifications. I haven't tried setting up an event in the
> WSAOVERLAPPED structure, but my understanding is that if the completion
> port
> isn't notified then the event won't be signaled either.
>
> Any help/thoughts/comments would be greatly appreciated...
>
> Thanks.


.



Relevant Pages