[ace-users] How to provide timeout for read operations in ACE_IOStream

Torsten Saliwada sally at gmx.net
Mon Sep 10 16:15:20 CDT 2007


ACE VERSION: 5.3

HOST MACHINE and OPERATING SYSTEM:
Windows XP SP2 on Dell D620 laptop running Intel Core 2 1.6Ghz , 2G RAM

Target same as Host

Running Visual Studio 6.0,
compiler: Microsoft (R) 32-bit C/C++ 

#include "ace/Time_Value.h"
#include "ace/IOStream_T.h"
#include "ace/SOCK_Connector.h"

#if defined (ACE_LACKS_ACE_IOSTREAM)


AREA/CLASS/EXAMPLE AFFECTED:

DOES THE PROBLEM AFFECT:
Usage

SYNOPSIS:
How to provide timeout for read operation in ACE_IOStream?


DESCRIPTION:
By using ACE_IOSTREAM there is a needs having timeout for read operation if methode eof has been used. Member recv_timeout_value_ could be set by using methode recv_timeout(ACE_Time_Value *tv) but I have not access to the underlying STREAM (ACE_Streambuf).
Example as following:

ACE_IOStream<ACE_SOCK_Stream> server;
// preparing IP connection object
ACE_SOCK_Connector connector;
ACE_INET_Addr addr( iPort, sIp.c_str() );

if( connector.connect( server, addr ) )
{
char c = 0;
while( !server.eof() )
{
server.recv( &c, 1 );
// do something
}
}
server.close();

There is an extract operator given but I don't know how to use it.
ACE_IOStream<STREAM> & operator>> (ACE_Time_Value *&tv);

Torsten


-- 
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail



More information about the Ace-users mailing list