Atrinik Server 2.5
Functions | Variables
socket/lowlevel.c File Reference
#include <global.h>
#include <zlib.h>

Go to the source code of this file.

Functions

void SockList_AddString (SockList *sl, const char *data)
char * GetString_String (uint8 *data, int len, int *pos, char *dest, size_t dest_size)
int SockList_ReadPacket (socket_struct *ns, int len)
int SockList_ReadCommand (SockList *sl, SockList *sl2)
void socket_enable_no_delay (int fd)
void socket_disable_no_delay (int fd)
static void socket_buffer_enqueue (socket_struct *ns, unsigned char *buf, size_t len, uint8 ndelay)
static void socket_buffer_dequeue (socket_struct *ns)
void socket_buffer_clear (socket_struct *ns)
void socket_buffer_write (socket_struct *ns)
void Send_With_Handling (socket_struct *ns, SockList *msg)
void Write_String_To_Socket (socket_struct *ns, char cmd, const char *buf, int len)
void write_cs_stats ()

Variables

CS_Stats cst_tot
CS_Stats cst_lst

Detailed Description

Low level socket related functions.

Definition in file lowlevel.c.


Function Documentation

char* GetString_String ( uint8 data,
int  len,
int *  pos,
char *  dest,
size_t  dest_size 
)

Construct a string from data packet.

Parameters:
dataData packet.
lenLength of 'data'.
[out]posPosition in the data packet.
destWill contain the string from data packet.
dest_sizeSize of 'dest'.
Returns:
'dest'.

Definition at line 59 of file lowlevel.c.

void Send_With_Handling ( socket_struct ns,
SockList msg 
)

Calls Write_To_Socket to send data to the client.

The only difference in this function is that we take a SockList, and we prepend the length information.

Parameters:
nsSocket to send the data to
msgThe SockList instance

Definition at line 341 of file lowlevel.c.

void socket_buffer_clear ( socket_struct ns)

Dequeue all socket buffers in the queue.

Parameters:
nsSocket to clear the socket buffers for.

Definition at line 257 of file lowlevel.c.

static void socket_buffer_dequeue ( socket_struct ns) [static]

Dequeue data from the socket buffer queue.

Parameters:
nsSocket we're going to dequeue the socket buffer from.

Definition at line 235 of file lowlevel.c.

static void socket_buffer_enqueue ( socket_struct ns,
unsigned char *  buf,
size_t  len,
uint8  ndelay 
) [static]

Enqueue data to the socket buffer queue.

Parameters:
nsThe socket we are adding the data to.
bufThe data.
lenNumber of bytes to add.
ndelayIf 1, will send this packet instantly without delay.

Definition at line 207 of file lowlevel.c.

void socket_buffer_write ( socket_struct ns)

Write data to socket.

Parameters:
nsThe socket we are writing to.

Definition at line 268 of file lowlevel.c.

void socket_disable_no_delay ( int  fd)

Disable TCP_NODELAY on the specified file descriptor (socket).

Parameters:
fdSocket's file descriptor.

Definition at line 191 of file lowlevel.c.

void socket_enable_no_delay ( int  fd)

Enable TCP_NODELAY on the specified file descriptor (socket).

Parameters:
fdSocket's file descriptor.

Definition at line 178 of file lowlevel.c.

void SockList_AddString ( SockList sl,
const char *  data 
)

Add a NULL terminated string.

Parameters:
slSockList instance to add to.
dataThe string to add.

Definition at line 37 of file lowlevel.c.

int SockList_ReadCommand ( SockList sl,
SockList sl2 
)

Read command from 'sl' and copy it to 'sl'.

Parameters:
slWhere to read command from.
sl2Where to copy the command.
Returns:
Length of the read command.

Definition at line 142 of file lowlevel.c.

int SockList_ReadPacket ( socket_struct ns,
int  len 
)

Reads from socket.

Parameters:
nsSocket to read from.
lenMax length of data to read.
Returns:
1 on success, -1 on failure.

Definition at line 81 of file lowlevel.c.

void write_cs_stats ( )

Writes out the gathered stats.

We clear cst_lst.

Definition at line 435 of file lowlevel.c.

void Write_String_To_Socket ( socket_struct ns,
char  cmd,
const char *  buf,
int  len 
)

Takes a string of data, and writes it out to the socket. A very handy shortcut function.

Definition at line 412 of file lowlevel.c.


Variable Documentation

Last series of stats.

Definition at line 429 of file lowlevel.c.

Life of the server.

Definition at line 426 of file lowlevel.c.