SourcePro® API Reference Guide

Product Documentation:
   SourcePro
Documentation Home
List of all members | Public Member Functions
RWBufferedSendPortal Class Reference

Provides buffering of send() calls only, possibly improving performance by limiting calls to the underlying RWPortal. More...

#include <rw/network/RWBufferedSendPortal.h>

Inheritance diagram for RWBufferedSendPortal:
RWPortal

Public Member Functions

 RWBufferedSendPortal (void)
 
 RWBufferedSendPortal (const RWPortal &portal, size_t bufferSize)
 
void flush (unsigned long timeout=0)
 
- Public Member Functions inherited from RWPortal
 RWPortal ()
 
 RWPortal (const RWPortal &x)
 
 ~RWPortal ()
 
RWPortaloperator= (const RWPortal &x)
 
RWNetBuf recv () const
 
int recv (char *buf, int bufLen, RWNetBuf::State *state=0) const
 
RWNetBuf recvAtLeast (int n) const
 
int recvAtLeast (char *buf, int bufLen, int n, RWNetBuf::State *state=0) const
 
int send (const RWCString &s) const
 
int send (const char *buf, int buflen) const
 
int sendAtLeast (const char *buf, int bufLen, int n) const
 
void sendAtLeast (const char *buf, int bufLen) const
 
int sendAtLeast (const RWCString &s, int n) const
 
void sendAtLeast (const RWCString &s) const
 

Additional Inherited Members

- Protected Member Functions inherited from RWPortal
 RWPortal (RWPortalImp *impl)
 
const RWPortalImpimplementation () const
 
RWPortalImpimplementation ()
 

Detailed Description

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:

Example
portal = RWBufferedSendPortal(portal, 1024);

Constructor & Destructor Documentation

RWBufferedSendPortal::RWBufferedSendPortal ( void  )

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

To use an instance created with this constructor, you must assign to it from a valid RWBufferedSendPortal instance.

RWBufferedSendPortal::RWBufferedSendPortal ( const RWPortal portal,
size_t  bufferSize 
)

Constructs a buffered portal on an existing portal. bufferSize is the requested size for the underlying buffer.

Member Function Documentation

void RWBufferedSendPortal::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 © 2021 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.