rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWTimedPortal Class Reference
[Essential Networking Module]

Provides timed send() and recv() calls. More...

#include <rw/network/RWTimedPortal.h>

Inheritance diagram for RWTimedPortal:
RWPortal

List of all members.

Public Member Functions

 RWTimedPortal ()
 RWTimedPortal (const RWPortal &portal, unsigned long timeout)

Detailed Description

RWTimedPortal inherits from RWPortal to provide timed send() and recv() calls. If send() and recv() calls on the underlying RWPortal might block for too long, RWTimedPortal provides a mechanism for breaking out of those calls after a pre-determined amount of time.

If the underlying RWPortal does not support timed send() and recv() calls, an RWNetTimeoutNotImplementedError exception is thrown the first time either send() or recv() is invoked.

If the specified timeout is exceeded in a call to send() or recv(), an RWNetOperationTimeoutError exception is thrown.

Examples

 #include <rw/network/RWInetAddr.h>
 #include <rw/network/RWTimedPortal.h>
 #include <rw/network/RWSocketPortal.h>
 
 int
 main()
 {
     RWWinSockInfo info;
 
     try {
         // make an address for echo port on localhost
         RWInetAddr address(7, RWInetHost::me());
 
         // make up some garbage data to send/recv
         RWCString outgoing("Hello World");
         RWCString incoming;
 
         // construct a socket-based portal to echo port
         RWSocketPortal portal(address);
 
         // create a timed portal on portal with a 100 ms timeout
         RWTimedPortal timed(portal, 100);
 
         // do an untimed send using original portal
         portal.send(outgoing);
 
         // do a timed recv using timed portal
         incoming = timed.recv();
     }
     catch(const RWxmsg& msg) {
         cerr << "Error: " << msg.why() << endl;
     }
     return 0;
 }

Constructor & Destructor Documentation

RWTimedPortal::RWTimedPortal (  ) 

Constructs an invalid RWTimedPortal. Attempts to send or receive on the portal throw an RWNetNoChannelError exception.

RWTimedPortal::RWTimedPortal ( const RWPortal portal,
unsigned long  timeout 
)

Constructs an RWTimedPortal from a portal object and a timeout. The RWTimedPortal object uses the underlying implementation from portal as the data sink for calls to send() and as the data source for calls to recv(). Passes the timeout parameter on every send and recv operation to that implementation.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.