#include <serversocket.h>
Inheritance diagram for ssobjects::ServerSocket::
Public Types | |
enum | { modeInvalid = 0, modeWriteOkay = 1, modeSendOkay = 2, modeReadOkay = 4, modeClosing = 8, modeNotified = 16, modeClosed = 32, modeValid = modeSendOkay|modeWriteOkay|modeReadOkay, modeAll = 0xFFFFFFFF } |
Not used. More... | |
Public Methods | |
ServerSocket (const unsigned32 nBufferSize=18000, const int iTimeout=DEFAULT_SOCKET_TIMEOUT) | |
ServerSocket (const SocketInstance &socket, const SockAddr &sa, const unsigned32 nBuffSize, const int iTimeout) | |
virtual | ~ServerSocket () |
void | sendPacket (const PacketBuffer &packet) |
Will add to outgoing buffer, and try sending it. More... | |
void | sendPacket (const PacketBuffer *const ppacket) |
Will add to outgoing buffer, and try sending it. More... | |
void | sendBuffer () |
Will attept to send any data in the outgoing buffer. More... | |
int | readData () |
Reads in as much data is available on the socket. More... | |
PacketBuffer* | extractPacket () |
Extracts a packet from the incoming buffer. More... | |
const Flags& | flags () const |
Returns the socket flags. (Not currently used.). More... | |
unsigned32 | getOutBufferSize () const |
Return bytes in outgoing buffer. More... | |
unsigned32 | getOutBufferSizeMax () const |
Return the actual size (how much was allocated) of the buffer. More... | |
unsigned32 | getInBufferSize () const |
Return bytes in incoming buffer. More... | |
unsigned32 | getBufferSizeMax () const |
How big the in/out buffer is. More... | |
SockAddr | getAddr () const |
Gets the socket address information of the connected socket. More... | |
int | socketTimeout () const |
Returns the number of seconds a send/receive operation will wait before throwing. More... | |
ServerHandler* | serverHandler () const |
Returns the ServerHandler object that was assigned to this server socket object. More... | |
void | setServerHandler (ServerHandler *s) |
Sets the ServerHandler object that this server socket will use. More... | |
Protected Methods | |
char* | getOutBuffer () const |
char* | getInBuffer () const |
void | rotateBuffer (char *pbuffer, unsigned32 nBuffSize, unsigned32 nBytesRotatingOut) |
void | addPacketBuffer (const PacketBuffer *const ppacket) |
ServerSocket (const ServerSocket &) | |
ServerSocket& | operator= (const ServerSocket &) |
Protected Attributes | |
ServerHandler* | m_pserverHandler |
SockAddr | m_socketAddr |
unsigned32 | m_nID |
int | m_iTimeout |
Flags | m_flags |
char* | m_pInBuff |
char* | m_pOutBuff |
char* | m_pOutPtr |
char* | m_pInPtr |
unsigned32 | m_nBytesIn |
unsigned32 | m_nBytesOut |
unsigned32 | m_nBufferSizeMax |
The Server Socket object contains an incoming buffer for data that is read in and isn't parsed, and an outgoing buffer for data that hasn't been sent. The SimpleServer object uses this object for every connection that comes in.
A ServerHandler object can be stored here for easy access to it from a server object that has a number of server socket objects.
|
Not used.
|
|
|
|
|
|
Deletes the in buffer, out buffer, and the server handler you assigned it. |
|
|
|
|
|
Extracts a packet from the incoming buffer. We do two checks to see that we have enough data to make a full packet. One check is to see that we have enough data the make a header. The second is to see if there is enough to make a packet with a header plus it's data. We return NULL if there wasn't enough data to make a full packet. If there is enough data we return _one_ complete packet, and make sure the buffer is ready to extract more packets, and recieve additional data. A full packet is the size of the packet header (all packets _must_ have full header) plus the size of any data. There doesn't always have to be any data with the packet. If the size that is read in is invalid, extractPacket throws an exception. This indicates that the data read in was not valid.
|
|
Returns the socket flags. (Not currently used.).
|
|
Gets the socket address information of the connected socket.
|
|
How big the in/out buffer is.
|
|
|
|
Return bytes in incoming buffer.
|
|
|
|
Return bytes in outgoing buffer.
|
|
Return the actual size (how much was allocated) of the buffer.
|
|
|
|
Reads in as much data is available on the socket. Reads data from the socket. Will only read as many bytes as will fit in our input buffer. If 0 bytes are available in the buffer, then recv will read 0 bytes. When this happens, a SocketInstanceException is thrown. This is desirable as if the buffer is full, and hasn't been processed, then it is considered an error.
|
|
|
|
Will attept to send any data in the outgoing buffer.
|
|
Will add to outgoing buffer, and try sending it.
|
|
Will add to outgoing buffer, and try sending it.
|
|
Returns the ServerHandler object that was assigned to this server socket object.
|
|
Sets the ServerHandler object that this server socket will use.
|
|
Returns the number of seconds a send/receive operation will wait before throwing.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|