$treeview $search $mathjax
Stratagus  2.2.7
$projectbrief
$projectbrief
$searchbox
-->
         _________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

metaserver/netdriver.cpp File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include "stratagus.h"
#include "netdriver.h"
#include "net_lowlevel.h"

netdriver.cpp - Session mangement (SDL_net Socket Implementation).

#define LINK(first, item, last, count)
#define UNLINK(first, item, last, count)
static Socket MasterSocket
SessionPoolPool
 external reference to session tracking.
ServerStruct Server
void Send (Session *session, const char *msg)
int ServerInit (int port)
void ServerQuit (void)
static int IdleSeconds (Session *session)
static int KillSession (Session *session)
static void AcceptConnections (void)
static void KickIdlers (void)
static int ReadData (void)
int UpdateSessions (void)

Define Documentation

#define LINK ( first,
item,
last,
count   ) 

Value:

{ \
        if (!first)                     \
                first = item;               \
        if (!last) {                    \
                last = item;                \
        } else {                        \
                item->Next = last->Next;    \
                last->Next = item;          \
                item->Prev = last;          \
                last = item;                \
                if (!item->Prev->Next)      \
                        item->Prev->Next = item;\
        }                               \
        ++count;                        \
}
LINK

Adds an item to a linked list.

#define UNLINK ( first,
item,
last,
count   ) 

Value:

{ \
        if (item->Prev)                   \
                item->Prev->Next = item->Next;\
        if (item->Next)                   \
                item->Next->Prev = item->Prev;\
        if (item == last)                 \
                last = item->Prev;            \
        if (item == first)                \
                first = item->Next;           \
        --count;                          \
}
UNLINK

Removes an item from the linked list.


Function Documentation

static void AcceptConnections ( void   )  [static]

Accept new connections

static int IdleSeconds ( Session session  )  [static]

Returns time (in seconds) that a session has been idle.

Parameters:
session This is the session we are checking.

static void KickIdlers ( void   )  [static]

Kick idlers

static int KillSession ( Session session  )  [static]

Destroys and cleans up session data.

Parameters:
session Reference to the session to be killed.

static int ReadData ( void   )  [static]

Read data

void Send ( Session session,
const char *  msg 
)

Send a message to a session

Parameters:
session Session to send the message to
msg Message to send

int ServerInit ( int  port  ) 

Initialize the server

Parameters:
port Defines the port to which the server will bind.
Returns:
0 for success, non-zero for failure

void ServerQuit ( void   ) 

ServerQuit: Releases the server socket.

int UpdateSessions ( void   ) 

Accepts new connections, receives data, manages buffers,


Variable Documentation

Socket MasterSocket [static]

external reference to session tracking.

(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.