#include <SocketPair.h>
Public Member Functions | |
SocketPair (NLsocket reliable=NL_INVALID, NLsocket unreliable=NL_INVALID) | |
Initializes this object, with optional initial values for the sockets. | |
~SocketPair () | |
Since this is just a class to contain the sockets, the sockets are not disconnected on exit. | |
void | disconnect () |
Calls a low-level disconnect (nlClose) on both sockets, if they are not NL_INVALID, and then sets them to NL_INVALID. | |
Address | getLocalAddress (bool reliable) const |
Address | getRemoteAddress (bool reliable) const |
ConnectionStats | getStats (int reliable) const |
int | rawRead (bool reliable, Buffer &buf) const |
Performs a low-level read on a socket. | |
int | rawWrite (bool reliable, const Buffer &buf) const |
Performs a low-level write on a socket. | |
Public Attributes | |
NLsocket | r |
The reliable socket. | |
NLsocket | u |
The unreliable socket. |
The GNE user will not need to use or know about this class, except to possibly pass it to another Connection type class to "evolve" a SyncConnection to an asyncronous type.
GNE::SocketPair::SocketPair | ( | NLsocket | reliable = NL_INVALID , |
|
NLsocket | unreliable = NL_INVALID | |||
) |
Initializes this object, with optional initial values for the sockets.
The value NL_INVALID should always be used for sockets that are not active.
Address GNE::SocketPair::getLocalAddress | ( | bool | reliable | ) | const |
Address GNE::SocketPair::getRemoteAddress | ( | bool | reliable | ) | const |
ConnectionStats GNE::SocketPair::getStats | ( | int | reliable | ) | const |
int GNE::SocketPair::rawRead | ( | bool | reliable, | |
Buffer & | buf | |||
) | const |
Performs a low-level read on a socket.
First, clear is called on the Buffer. Then the read is performed. The number of bytes read is set to be the new limit, and this number is returned. The position is set to 0. Up get getCapacity bytes will be read.
I do know that this is undeseriable functionality but these are the semantics that were used with the old RawPacket, and since SocketPair is an internal GNE class, I kept the semantics. Preferably, the rawRead and rawWrite functions should work based on getRemaining on the Buffer and act as if they are reading or writing bytes from the Buffers, so that their positions change.
reliable | select which socket to perform read on. | |
buf | data arrives in this buffer. |
int GNE::SocketPair::rawWrite | ( | bool | reliable, | |
const Buffer & | buf | |||
) | const |
Performs a low-level write on a socket.
I do know that this is undeseriable functionality but these are the semantics that were used with the old RawPacket, and since SocketPair is an internal GNE class, I kept the semantics. Preferably, the rawRead and rawWrite functions should work based on getRemaining on the Buffer and act as if they are reading or writing bytes from the Buffers, so that their positions change.
reliable | select which socket to perform the write on. If their is no unreliable socket, it is sent on the reliable one instead. | |
buf | data to be sent. The data from the Buffer's 0 position to the Buffer's current position is sent. |