Module: Essential Networking Module Package: Networking
Does not inherit
#include <rw/network/RWPortal.h>
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.
RWPortals are lightweight objects. 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.
RWPortals are 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.
RWPortal();
Creates a portal that cannot send or receive. Trying to send or receive throws an RWNetNoChannelError exception.
RWPortal(const RWPortal& x);
Copy constructor.
~RWPortal();
Destroys this portal. If other portals were created from this one by assignment or copying, they are unaffected.
RWPortal& operator=(const RWPortal& x);
Assignment operator. Makes self a portal to the same channel as x. Disconnects from the current channel, if any.
RWNetBuf recv() const; int 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 recvAtLeast(int n) const; int 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.
int send(const RWCString& s) const; int send(const char* buf, int buflen) const;
Sends a buffer of data. Returns the number of bytes actually sent. send() makes only one call to the communications channel.
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;
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.
RWPortal(RWPortalImp *impl);
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 RWPortalImps, must live on the heap.
bool operator==(const RWPortal& p, const RWPortal& q);
Returns true if p and q both use the same underlying portal implementation object.
const RWPortalImp* implementation() const; RWPortalImp* implementation();
Provides derived classes access to the underlying 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.