rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWPortal Class Reference
[Essential Networking Module]

An access point to a reliable byte stream communication channel. More...

#include <rw/network/RWPortal.h>

Inheritance diagram for RWPortal:
RWBufferedRecvPortal RWBufferedSendPortal RWSecureSocketPortal RWSocketPortal RWTimedPortal

List of all members.

Public Member Functions

 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

Protected Member Functions

 RWPortal (RWPortalImp *impl)
const RWPortalImpimplementation () const
RWPortalImpimplementation ()

Friends

bool operator== (const RWPortal &p, const RWPortal &q)

Detailed Description

RWPortal is an access point to a reliable byte stream communication channel. It is possible for more than one RWPortal to access the same communications channel. This happens, for example, when using the copy constructor and assignment operator. Unless explicitly constructed otherwise, portal classes are designed so that when the last portal into a channel disappears, the communications channel is closed.

RWPortal is a lightweight object. In addition, the copy constructor and the assignment operator copy only the RWPortal and not the underlying communications channel, which means that those operations are inexpensive. As a result, RWPortals can be returned by value from functions and used as member data in objects.

RWPortal is implemented using the interface/implementation design pattern as described in the Essential Networking Module User's Guide. The RWPortal itself is really a handle to an implementation that represents the communication channel.


Constructor & Destructor Documentation

RWPortal::RWPortal (  )  [inline]

Creates a portal that cannot send or receive. Trying to send or receive throws an RWNetNoChannelError exception.

RWPortal::RWPortal ( const RWPortal x  )  [inline]

Copy constructor.

RWPortal::~RWPortal (  )  [inline]

Destroys this portal. If other portals were created from this one by assignment or copying, they are unaffected.

RWPortal::RWPortal ( RWPortalImp impl  )  [inline, protected]

Specifies the portal implementation. This constructor is used by derived classes that create specific types of portals by passing in specific types of portal implementations. The argument, like all RWPortalImp instances, must live on the heap.


Member Function Documentation

RWPortalImp* RWPortal::implementation (  )  [inline, protected]

Provides derived classes access to the underlying implementation.

const RWPortalImp* RWPortal::implementation (  )  const [inline, protected]

Provides derived classes access to the underlying implementation.

RWPortal & RWPortal::operator= ( const RWPortal x  )  [inline]

Assignment operator. Makes self a portal to the same channel as x. Disconnects from the current channel, if any.

int RWPortal::recv ( char *  buf,
int  bufLen,
RWNetBuf::State state = 0 
) const

Receives a buffer of data. The version returning an int returns the number of characters actually received. recv() makes only one call to the communications channel.

RWNetBuf RWPortal::recv ( void   )  const [inline]

Receives a buffer of data. The version returning an int returns the number of characters actually received. recv() makes only one call to the communications channel.

int RWPortal::recvAtLeast ( char *  buf,
int  bufLen,
int  n,
RWNetBuf::State state = 0 
) const

Receives at least n characters into the buffer. The second version returns the number of bytes actually received. The implementation loops over recv() until either all the data is received or, for some reason, no data is returned. If no data is returned by recv(), an RWNetCantRecvError exception is thrown. If you call recvAtLeast() on a non-blocking channel, it will probably throw this same exception.

RWNetBuf RWPortal::recvAtLeast ( int  n  )  const

Receives at least n characters into the buffer. The second version returns the number of bytes actually received. The implementation loops over recv() until either all the data is received or, for some reason, no data is returned. If no data is returned by recv(), an RWNetCantRecvError exception is thrown. If you call recvAtLeast() on a non-blocking channel, it will probably throw this same exception.

int RWPortal::send ( const char *  buf,
int  buflen 
) const [inline]

Sends a buffer of data. Returns the number of bytes actually sent. send() makes only one call to the communications channel.

int RWPortal::send ( const RWCString s  )  const [inline]

Sends a buffer of data. Returns the number of bytes actually sent. send() makes only one call to the communications channel.

void RWPortal::sendAtLeast ( const RWCString s  )  const

Sends at least n characters into the communications channel. If n is omitted, all of the data is sent where appropriate, and the number of bytes actually sent is returned. The implementation loops over send() to send the data. If any of the calls to send() cannot send any data, an RWNetCantSendError exception is thrown. If sendAtLeast() is called on a non-blocking channel, it will probably throw this same exception.

int RWPortal::sendAtLeast ( const RWCString s,
int  n 
) const [inline]

Sends at least n characters into the communications channel. If n is omitted, all of the data is sent where appropriate, and the number of bytes actually sent is returned. The implementation loops over send() to send the data. If any of the calls to send() cannot send any data, an RWNetCantSendError exception is thrown. If sendAtLeast() is called on a non-blocking channel, it will probably throw this same exception.

void RWPortal::sendAtLeast ( const char *  buf,
int  bufLen 
) const [inline]

Sends at least n characters into the communications channel. If n is omitted, all of the data is sent where appropriate, and the number of bytes actually sent is returned. The implementation loops over send() to send the data. If any of the calls to send() cannot send any data, an RWNetCantSendError exception is thrown. If sendAtLeast() is called on a non-blocking channel, it will probably throw this same exception.

int RWPortal::sendAtLeast ( const char *  buf,
int  bufLen,
int  n 
) const

Sends at least n characters into the communications channel. If n is omitted, all of the data is sent where appropriate, and the number of bytes actually sent is returned. The implementation loops over send() to send the data. If any of the calls to send() cannot send any data, an RWNetCantSendError exception is thrown. If sendAtLeast() is called on a non-blocking channel, it will probably throw this same exception.


Friends And Related Function Documentation

bool operator== ( const RWPortal p,
const RWPortal q 
) [friend]

Returns true if p and q both use the same underlying portal implementation object.

 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.