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

VMWare Workstation DNS doesn't work right

VMWare workstation is in many ways a great product. It allows you to do all kinds of nifty set-ups that let multiple virtual machines talk to each other and the rest of the world, within the confines of your local PC.

However, there are some problems with it. I have a couple of virtual machines that I use as a sandbox for developing networked applications at work. These are hosted inside a Dell Inspiron XPS 1330 laptop. The laptop travels between networks frequently. At work, it's usually plugged in, but sometimes gets un-plugged and goes on wireless-G. On the train, it goes on a Sprint WAN card. At home, it generally goes on another wireless-G network.

jwatte's picture

A simple approach to native network marshalling

I used to do serialization using all kinds of fancy templates and macros. You can create pretty elegant systems that way. However, at some point, simplicity should win out. Here's a system that might work just fine for you:

A simple packet class, which really is all you need:

class packet {
public:
  packet() : pos_(0) {}
  void append(void const *data, size_t size) {

jwatte's picture

How to structure a reusable game networking library

I recently have answered several questions about how to structure a networking library such that it can be easy to use for users of the library and/or when expanding the game you're writing. Here are some thoughts on that. (Code examples in C++)

Networking generally ends up needing to do three things:

1) Mirror state updates from one object to another.
2) Request remote services ("RPC").

jwatte's picture

Animated illustration of how a networked game server works

Here's a general illustration of how a networked game server works. While the animation is somewhat fast, you can just fix your eyes on a particular spot and read the explanation text as it shows up.

jwatte's picture

main.cpp

#include "etwork/etwork.h"
#include "etwork/buffer.h"
#include "etwork/errors.h"
#include "etwork/notify.h"
#include "etwork/marshal.h"
 
#include <assert.h>
#include <stdio.h>
#include <string>
#include <math.h>
 
#if defined( NDEBUG )
#pragma warning( disable: 4101 )  //  unreferenced local variable
#endif
 
 
void TestEtworkCreate()
{
  EtworkSettings es;

jwatte's picture

tester

A simple command-line program that exercises parts of the Etwork API and asserts if something fails. Think of it as an API acceptance test.

jwatte's picture

sockimpl.h

#if !defined( etwork_sockimpl_h )
#define etwork_sockimpl_h
 
#include "etwork/etwork.h"
#include "etwork/locker.h"
#include "etwork/buffer.h"
#include "etwork/timer.h"
#include "etwork/errors.h"
#include "etwork/notify.h"
 
#if defined( WIN32 )
#include <windows.h>
#endif
 
#include <stdio.h>  //  for _snprintf
#include <math.h>
 
#include <string>
#include <map>

jwatte's picture

socketbase.cpp

#include "sockimpl.h"
 
using namespace etwork;
using namespace etwork::impl;
 
 
SocketManager::SocketManager()
{
  listening_ = INVALID_SOCKET;
  maxNumSocks_ = FD_SETSIZE;
  numSocks_ = 0;
  maxSock_ = 0;
  allSet_ = (fd_set *)::operator new( sizeof(fd_set) );
  FD_ZERO( allSet_ );
  readSet_ = (fd_set *)::operator new( sizeof(fd_set) );
  FD_ZERO( readSet_ );

jwatte's picture

marshal.cpp

#include <assert.h>
#include <string>
#include <math.h>
#include <map>
 
#include "etwork/marshal.h"
 
namespace marshaller {
 
inline std::string operator+( std::string const & left, int right ) {
  char buf[24];
  sprintf( buf, "%d", right );
  return left + std::string( buf );
}
 
inline std::string operator+( std::string const & left, size_t right ) {
  char buf[24];

jwatte's picture

errors.cpp

#include "sockimpl.h"
#include <stdarg.h>
 
using namespace etwork;
using namespace etwork::impl;
 
#if !defined( NDEBUG )
bool etwork::impl::gDebugging = true;
#else
bool etwork::impl::gDebugging = false;
#endif
 
bool etwork::impl::wsOpen = false;
 
Lock etwork::impl::gethostLock; //!< gethostbyname is not thread safe
 
IErrorNotify * etwork::impl::gErrorNotify;

Syndicate content