#include <bufferedsocket.h>
Inheritance diagram for ssobjects::BufferedSocket::
Public Types | |
enum | ReleaseFlag { autoRelease, noRelease } |
Public Methods | |
BufferedSocket () | |
Construct the socket. More... | |
~BufferedSocket () | |
Destroys the socket, and closes the connection. More... | |
int | sendPacket (PacketBuffer *pPacket, const ReleaseFlag release=noRelease) |
Transmits the packet. More... | |
int | sendPacket (PacketBuffer &packet) |
Transmits the packet. More... | |
PacketBuffer * | recvPacket () |
Reads and waits for a full PacketBuffer object. More... | |
PacketBuffer * | recvPacket (PacketBuffer &packet) |
Reads and waits for a full PacketBuffer object. More... | |
int | setTimeout (const int iTimeOut) |
Sets how long to wait for incoming data before throwing. More... | |
void | operator<< (PacketBuffer &packet) |
Transmits the packet. More... | |
void | operator<< (PacketBuffer *ppacket) |
Transmits the packet. More... | |
void | operator>> (PacketBuffer &packet) |
Reads and waits for a full PacketBuffer object. More... |
When data is sent, not all data is garenteed to be sent in the one call. (See man page for send(3) for details.)
When data is read, or received, not all the data is garenteed to be read in one recv call. (See man page for recv(3) for details.)
To make life easier, the functionality for sending and receiving an entire PacketBuffer object, without multiple calls to send()/recv() is wrapped up in this object.
Also, if 3 packets were sent, but only 2 1/2 were read, BufferedSocket will parse out the two, and keep the data from 3 till the next call.
|
|
|
Construct the socket.
|
|
Destroys the socket, and closes the connection.
|
|
Transmits the packet.
|
|
Transmits the packet.
|
|
Reads and waits for a full PacketBuffer object.
|
|
Reads and waits for a full PacketBuffer object. Reads data into the referenced packet. This isn't as effiecent as using recvPacket(). You are gerented to receive a full PacketBuffer object.
|
|
Reads and waits for a full PacketBuffer object. Reads data and returns a pointer to a new PacketBuffer object. You are responsible for deleting the returned packet when you are finished with it. You are gerented to receive a full PacketBuffer object. When data is read in, some verification is done to ensure that the packet header is valid. There is no way to validate the buffer portion of the packet. A test is done on the header to see if the cookie (just a constant value passed all the time) and to see the the command looks like it might be valid. There is no way to tell other then if the command is zero (PacketBuffer::pcInvalid). Note that a common problem with getting PacketBuffer::pcInvalid as a command is not setting the command in a packet before sending it. If a packet is sent with a size greater then 3000 bytes, the read operation will reset the internal buffer, and throw an exception. This is done to prevent bogus packets overflowing the buffer.
|
|
Transmits the packet.
|
|
Transmits the packet. Sends the data pointed to by pPacket, and optionaly destroys the memory pointed to by pPacket once the data is sent. All data is garented to be sent.
|
|
Sets how long to wait for incoming data before throwing. Sets how many seconds a read or send operation will wait before throwing an exception. |