Module: Essential Networking Module Package: Networking
RWTimedPortalRWPortal
#include <rw/network/RWTimedPortal.h>
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.
#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; }
RWTimedPortal();
Constructs an invalid RWTimedPortal. Attempts to send or receive on the portal throw an RWNetNoChannel exception.
RWTimedPortal(const RWPortal& portal, unsigned long ms);
Constructs an RWTimedPortal from a portal object and a timeout. The RWTimedPortal object uses the portal's underlying implementation 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.
© 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.