[Ace-users] ACE_Proactor, asynch read/write and timeouts

Andi aheusser at gmail.com
Tue Feb 12 14:14:04 CST 2008


PRF:

    ACE VERSION: 5.6

    HOST MACHINE and OPERATING SYSTEM:
        Dell, Intel Core2 6600 2.4GHz, 2GB RAM
        Windows XP Professional, WINSOCK2

    TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
        same as host
    COMPILER NAME AND VERSION (AND PATCHLEVEL):
        MS Visual C++ 2005 (msvc)

    AREA/CLASS/EXAMPLE AFFECTED:
        Proactor, TCP sockets

    DOES THE PROBLEM AFFECT:
        COMPILATION?
        LINKING?
            On Unix systems, did you run make realclean first?
        EXECUTION?
        OTHER (please specify)?
             Just general question/clarification


    SYNOPSIS:
When using the Proactor pattern to asynchronously send and receive
data via TCP sockets, is there a way to have those asynch operations
timeout?

    DESCRIPTION:
I'd like to find out if there is a way to have a
ACE_Asynch_Read_Stream::readv(...) or
ACE_Asynch_Write_Stream::writev(...) operation timeout if it takes to
long. I have tried setting the socket options like
"
int sendTimeout=3000; //3 sec timeout
ACE_OS::setsockopt(handle(), SOL_SOCKET, SO_SNDTIMEO, (char
*)&sendTimeout, sizeof (m_sendTimeout))
"
but that didn't have any effect. I've also tried set the
msg_deadline_time in the message block in absolute date/time terms but
that didn't seem to work either.
In my test I created a listening socket (server) via the ACE_Acceptor
and created a socket (client) that connected to it using the
ACE_Connector. Then I send some data from the client to the server
without doing the 'readv' on the server first. So the client's writev
is stuck indefinitely and I get the handle_write_stream callback once
I do the 'readv' on the server.

Is there some way of having that operation cancel/timeout after a
predefined time?

Also what's the msg_deadline_time in the message block all about?

And I'm assuming that the 'handle_timeout' callback method in the
ACE_Handler base class is for the case where a timer through the
Proactor would be created because I never get any callbacks. Initially
I thought that maybe I'd get a callback there if the write or read
operation takes too long and times out.

Or would I need to create a timer for this timeout event? But then how
would I be able to cancel the read/write operation in question? Would
I just call ACE_Asynch_Write_Stream::cancel()?

Thanks.
Andi


More information about the Ace-users mailing list