SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWPortal Class Reference

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

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
 
int recvAtLeast (char *buf, int bufLen, int n, RWNetBuf::State *state=0) const
 
RWNetBuf recvAtLeast (int n) const
 
int send (const char *buf, int buflen) const
 
int send (const RWCString &s) const
 
void sendAtLeast (const char *buf, int bufLen) const
 
int sendAtLeast (const char *buf, int bufLen, int n) const
 
void sendAtLeast (const RWCString &s) const
 
int sendAtLeast (const RWCString &s, int n) const
 

Protected Member Functions

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

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() [1/3]

RWPortal::RWPortal ( )
inline

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

◆ RWPortal() [2/3]

RWPortal::RWPortal ( const RWPortal & x)
inline

Copy constructor.

◆ ~RWPortal()

RWPortal::~RWPortal ( )
inline

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

◆ RWPortal() [3/3]

RWPortal::RWPortal ( RWPortalImp * impl)
inlineprotected

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

◆ implementation() [1/2]

RWPortalImp * RWPortal::implementation ( )
inlineprotected

Provides derived classes access to the underlying implementation.

◆ implementation() [2/2]

const RWPortalImp * RWPortal::implementation ( ) const
inlineprotected

Provides derived classes access to the underlying implementation.

◆ operator=()

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.

◆ recv() [1/2]

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.

◆ recv() [2/2]

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.

◆ recvAtLeast() [1/2]

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.

◆ recvAtLeast() [2/2]

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.

◆ send() [1/2]

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.

◆ send() [2/2]

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.

◆ sendAtLeast() [1/4]

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

Sends at least n characters into the communications channel. If n is omitted, all 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.

◆ sendAtLeast() [2/4]

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 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.

◆ sendAtLeast() [3/4]

void RWPortal::sendAtLeast ( const RWCString & s) const

Sends at least n characters into the communications channel. If n is omitted, all 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.

◆ sendAtLeast() [4/4]

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

Sends at least n characters into the communications channel. If n is omitted, all 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 Symbol Documentation

◆ operator==

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

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

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.