Code Snippet

warning: Creating default object from empty value in /home/hplus/enchantedage.com/modules/taxonomy/taxonomy.pages.inc on line 33.
This article contains a little code.
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;

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.rc

// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
 
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
 
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

jwatte's picture

resource.h

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by chatserver.rc
//
#define IDD_USERLIST                    101
#define IDD_HOSTDIALOG                  102
#define IDC_BUTTON1                     1001
#define IDC_KICK                        1001
#define IDC_USERLIST                    1002
#define IDC_PORTNUM                     1003

Syndicate content