TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
NetworkDevice.h File Reference
#include "G3D/platform.h"
#include "G3D/NetAddress.h"
#include <string>
#include <iostream>
#include "G3D/g3dmath.h"
#include "G3D/ReferenceCount.h"
#include "G3D/Array.h"
#include "G3D/BinaryOutput.h"
+ Include dependency graph for NetworkDevice.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  G3D::Conduit
 
class  G3D::ReliableConduit
 
class  G3D::LightweightConduit
 
class  G3D::LightweightConduit::PacketSizeException
 
class  G3D::NetListener
 
class  G3D::NetworkDevice
 Abstraction of network (socket) functionality. More...
 
class  G3D::NetworkDevice::EthernetAdapter
 Description of an ethernet or wireless ethernet adapter. More...
 

Namespaces

 G3D
 

Typedefs

typedef shared_ptr< class
ReliableConduit > 
G3D::ReliableConduitRef
 
typedef shared_ptr< class
LightweightConduit > 
G3D::LightweightConduitRef
 
typedef shared_ptr< class
NetListener > 
G3D::NetListenerRef
 

Detailed Description

These classes abstract networking from the socket level to a serialized messaging style that is more appropriate for games. The performance has been tuned for sending many small messages. The message protocol contains a header that prevents them from being used with raw UDP/TCP (e.g. connecting to an HTTP server).

LightweightConduit and ReliableConduits have different interfaces because they have different semantics. You would never want to interchange them without rewriting the surrounding code.

NetworkDevice creates conduits because they need access to a global log pointer and because I don't want non-reference counted conduits being created.

Be careful with threads and reference counting. The reference counters are not threadsafe, and are also not updated correctly if a thread is explicitly killed. Since the conduits will be passed by const XConduitRef& most of the time this doesn't appear as a major problem. With non-blocking conduits, you should need few threads anyway.

LightweightConduits preceed each message with a 4-byte host order unsigned integer that is the message type. This does not appear in the message serialization/deserialization.

ReliableConduits preceed each message with two 4-byte host order unsigned integers. The first is the message type and the second indicates the length of the rest of the data. The size does not include the size of the header itself. The minimum message is 9 bytes:a 4-byte type, a 4-byte header equal to "1", and one byte of data.

Morgan McGuire, http://graphics.cs.williams.edu 2002-11-22 2006-11-25