Module: Essential Networking Module Package: Networking
RWBufferedSendPortalRWPortal
#include <rw/network/RWBufferedSendPortal.h>
RWBufferedSendPortal inherits from RWPortal to provide buffering of send() calls. In cases where calling send() on the underlying RWPortal is expensive, RWBufferedSendPortal may substantially increase efficiency by limiting the number of calls to the underlying RWPortal.
NOTE -- When buffering send data, requests to send data should be made through the RWBufferedSendPortal object. If you must make calls directly to the underlying RWPortal, be sure to call flush() first. Failure to do so may result in data being transmitted out of order.
Buffered data in the RWBufferedSendPortal is sent through the underlying RWPortal when any of the following three conditions are met:
the RWBufferedSendPortal is destroyed
the flush() method is invoked
the buffer becomes full
RWPortal portal = RWSocketPortal(); portal = RWBufferedSendPortal(portal, 1024);
RWBufferedSendPortal(void);
Constructs an invalid RWBufferedSendPortal. Attempts to send or receive on the portal throw an RWNetNoChannel exception.
To use an instance created with this constructor, you must assign to it from a valid RWBufferedSendPortal instance.
RWBufferedSendPortal(const RWPortal& portal, size_t bufferSize);
Constructs a buffered portal on an existing portal. bufferSize is the requested size for the underlying buffer.
void flush(unsigned long timeout = 0);
Sends any data in the send buffer immediately. This function does not affect data in the recv buffer, or a portal that is not buffering send data.
The parameter timeout specifies the maximum amount of time in milliseconds to wait for any single blocking send() call. There may be multiple such calls made in a single call to flush(). If a timeout is not specified, or is 0, this method blocks indefinitely.
This function throws a RWNetCantSendError exception if the send() call on the underlying portal returns an error or fails to send any data.
© 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.