Networking

warning: Creating default object from empty value in /home/hplus/enchantedage.com/modules/taxonomy/taxonomy.pages.inc on line 33.
Computers talking to computers.
jwatte's picture

buffer.cpp

#include "etwork/buffer.h"
 
#include <string.h>
#include <deque>
#include <assert.h>
 
using namespace etwork;
 
//! The framing protocol for etwork::Buffer is simple: each packet is 
//! preceded by a two-byte length, in network-endian order.
//! If random data is received, this may result in arbitrary packet 

jwatte's picture

block.cpp

#include "etwork/marshal.h"
 
 
Block::Block( void * base, size_t size )
{
  buf_ = (unsigned char *)base;
  size_ = size;
  pos_ = 0;
  deleteIt_ = false;
  atEof_ = false;
}
 
Block::Block( size_t size )
{
  buf_ = (unsigned char *)::operator new( size );
  size_ = size;
  pos_ = 0;
  deleteIt_ = true;
  atEof_ = false;
}
 
Block::~Block()
{
  if( deleteIt_ ) {

jwatte's picture

lib

Source code for the actual library -- includes code that calls WinSock to do actual network I/O.

jwatte's picture

etwork

Public headers (API) for the Etwork networking library.

jwatte's picture

chatserver.cpp

//  chatserver.cpp
//  The Win32 GUI for the chat server sample.
//  This file runs the dialogs, and defers to the chathost.cpp 
//  file for networking and user management.
 
#include <winsock2.h>
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
 
#include <string>
 
#include "etwork/etwork.h"
#include "etwork/timer.h"

jwatte's picture

chathost.h

//  chathost.h
//  This file defined a simple interface for a service that 
//  hosts text chat over a specific port.
//  Intended as a sample for how to use the message-layer 
//  functionality of the Etwork networking library.
//  <a href="http://www.mindcontrol.org/etwork/</p>
<p>#if" title="http://www.mindcontrol.org/etwork/</p>
<p>#if">http://www.mindcontrol.org/etwork/</p>
<p>#if</p></a> !defined( chathost_h )
#define chathost_h
 
//  Information kept about each client.
struct ChatClient {

jwatte's picture

chathost.cpp

//  chathost.cpp
//  Illustrates how you can wrap Etwork into a layer 
//  that understands commands, such as "log in," "log out" 
//  and "pass on this text".
 
#include "etwork/etwork.h"
#include "etwork/timer.h"
#include "chathost.h"
 
#include <assert.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>

jwatte's picture

chatclient.cpp

//  chatclient.cpp
//  This file is an example of how to write a client program 
//  using the Etwork networking message API.
//  It is intended to communicate with a server running 
//  the "chatserver.cpp/chathost.cpp" code, over TCP or UDP.
 
#include "etwork/etwork.h"
#include "etwork/timer.h"
#include "etwork/errors.h"
#include "resource.h"

jwatte's picture

chatclient

The sample client program in the Etwork networking library.

jwatte's picture

Online Browsable Source-code

These pages contain the source code for Etwork version 0.4, in online browsable form.

Syndicate content