Sleipnir
Static Public Member Functions
Sleipnir::CSeekNetwork Class Reference

Utilities for sending and receiving data over the network. More...

#include <seeknetwork.h>

Static Public Member Functions

static int Send (int, const string &)
 Send a string.
static int Send (int, const vector< float > &)
 Send a float array.
static int Send (int, char *, int)
 Low-level send function.
static void Clear (char *, int)
 Clear a char array.
static int Copy (char *, char *, int, int)
 Copy a char array.
static int Receive (int, string &)
 Receive a string.
static int Receive (int, vector< float > &)
 Receive a float array.

Detailed Description

Utilities for sending and receiving data over the network.

This class provides static utility functions to facilitate the exchange of messages between the Seek client and the Seek server. In order to allow this exchange to occur, all messages must conform to a uniform standard.

Outgoing messages

On the sending end, all outgoing messages must first begin with a message header that specifies the length and the type of the message. Then the body of the message follows.

The supported outgoing messages are: an array of chars (such as a string), an array of floats. The outgoing message is structured as follows:

IMPORTANT: Outgoing messages are always encoded using bytes in the Little Endian order.

Incoming messages

On the receiving end, CSeekNetwork also supports the receiving of a char array (or a string) or a float array.

In order to be properly recognized, the incoming message should be structured as follows:

For a char array:

For a float array:

IMPORTANT: For an incoming message to be properly recognized, the incoming message should also be encoded with bytes in the Little Endian order.

Definition at line 59 of file seeknetwork.h.


Member Function Documentation

void Sleipnir::CSeekNetwork::Clear ( char *  b,
int  size 
) [static]

Clear a char array.

Clears a char array by zeroing all bytes

Parameters:
bThe char array
sizeThe size of the char array

Definition at line 90 of file seeknetwork.cpp.

int Sleipnir::CSeekNetwork::Copy ( char *  d,
char *  s,
int  beg,
int  num 
) [static]

Copy a char array.

Copies the entire source array (0...N) to the destination array beginning at the index beg

Parameters:
dThe destination
sThe source
begThe position on the destination array where the pasting starts
numThe size of the source array
Returns:
beg + num

Definition at line 97 of file seeknetwork.cpp.

Referenced by Send().

int Sleipnir::CSeekNetwork::Receive ( int  new_fd,
string &  s 
) [static]

Receive a string.

Receive a string from the client

Parameters:
new_fdThe client socket
sThe string where the message will be received to
Remarks:
Assumes that the client connection has been established.

Definition at line 161 of file seeknetwork.cpp.

int Sleipnir::CSeekNetwork::Receive ( int  new_fd,
vector< float > &  f 
) [static]

Receive a float array.

Receive a float array from the client

Parameters:
new_fdThe client socket
fThe float array where the message will be received to
Remarks:
Assumes that the client connection has been established.

Definition at line 105 of file seeknetwork.cpp.

int Sleipnir::CSeekNetwork::Send ( int  new_fd,
const string &  str 
) [static]

Send a string.

Encodes an outgoing message and sends it to the client

Parameters:
new_fdThe client socket
strThe string to be sent to the client
Remarks:
Assumes that the client connection has been established.

Definition at line 15 of file seeknetwork.cpp.

Referenced by Sleipnir::CSeekTools::ReadDatabaselets(), and Send().

int Sleipnir::CSeekNetwork::Send ( int  new_fd,
const vector< float > &  f 
) [static]

Send a float array.

Encodes an outgoing message and sends it to the client

Parameters:
new_fdThe client socket
strThe array of floats to be sent to the client
Remarks:
Assumes that the client connection has been established.

Definition at line 38 of file seeknetwork.cpp.

References Send().

int Sleipnir::CSeekNetwork::Send ( int  new_fd,
char *  c,
int  size 
) [static]

Low-level send function.

Parameters:
new_fdThe client socket
cThe message
sizeThe message length
Returns:
-1 if an error occurs or size if the sending is successful
Remarks:
Assumes that the client connection has been established.

Definition at line 66 of file seeknetwork.cpp.

References Copy().


The documentation for this class was generated from the following files: