C++ Sockets Library documentation

C++ Sockets Library

Name of changed file

Version and , fileVersion and , file
Line 1 in Line 1 in
Context line
Removed line
Changed line
Context line
Context line
Changed line
Added line
Context line

Exception.cpp

/usr/src/Sockets-2.3/Exception.cpp Sun Nov 4, 2007./Exception.cpp Tue Jul 1, 2008
Line 24 in Exception.cppLine 24 in Exception.cpp
#pragma warning(disable:4786)
#endif
#include "Exception.h"
#include "Utility.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
Line 32 in Exception.cppLine 33 in Exception.cpp
Exception::Exception(const std::string& description) : m_description(description)
, m_stack(Utility::Stack())
{
}
Line 42 in Exception.cppLine 44 in Exception.cpp
}
const std::string Exception::Stack() const
{
return m_stack;
}
#ifdef SOCKETS_NAMESPACE
} // namespace SOCKETS_NAMESPACE {
#endif

Exception.h

/usr/src/Sockets-2.3/Exception.h Tue Feb 12, 2008./Exception.h Tue Jul 1, 2008
Line 39 in Exception.hLine 39 in Exception.h
virtual ~Exception() {}
virtual const std::string ToString() const;
virtual const std::string Stack() const;
Exception(const Exception& ) {} // copy constructor
Line 46 in Exception.hLine 47 in Exception.h
private:
std::string m_description;
std::string m_stack;
};

File.cpp

/usr/src/Sockets-2.3/File.cpp Fri Feb 1, 2008./File.cpp Thu Jul 3, 2008
Line 30 in File.cppLine 30 in File.cpp
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifndef _WIN32
#include <unistd.h>
#endif
#include "File.h"

ISocketHandler.h

/usr/src/Sockets-2.3/ISocketHandler.h Wed Jan 23, 2008./ISocketHandler.h Thu Jun 19, 2008
Line 100 in ISocketHandler.hLine 100 in ISocketHandler.h
// -------------------------------------------------------------------------
/** Add socket instance to socket map. Removal is always automatic. */
virtual void Add(Socket *) = 0;
private:
/** Remove socket from socket map, used by Socket class. */
virtual void Remove(Socket *) = 0;
public:
// -------------------------------------------------------------------------
/** Add socket instance to socket map. Removal is always automatic. */
virtual void Add(Socket *) = 0;
protected:
/** Remove socket from socket map, used by Socket class. */
virtual void Remove(Socket *) = 0;
public:

Makefile

/usr/src/Sockets-2.3/Makefile Fri May 30, 2008./Makefile Sun Jul 27, 2008
Line 6 in MakefileLine 6 in Makefile
# solaris8
PLATFORM = linux-x86-32
# .h files installed to $(PREFIX)/include/Sockets
# static lib .a files installed to $(PREFIX)/lib
PREFIX = /usr/local
# include paths
INCLUDE =
include Makefile.version
# solaris8
PLATFORM = linux-x86-32
# .h files installed to $(DESTDIR)/$(PREFIX)/include/Sockets
# static lib .a files installed to $(DESTDIR)/$(PREFIX)/lib
PREFIX = /usr/local
# include paths
INCLUDE = -I/usr/local/include/libxml2
include Makefile.version
Line 54 in MakefileLine 54 in Makefile
$(HTDOCS)/Sockets/latest_diff.html
install: all
@mkdir -p $(PREFIX)/lib
cp libSockets.a $(PREFIX)/lib
@mkdir -p $(PREFIX)/include/Sockets
cp -a *.h $(PREFIX)/include/Sockets
@rm -f $(PREFIX)/include/Sockets/SSLSocket.*
@rm -f $(PREFIX)/include/Sockets/HttpsGetSocket.*
@rm -f $(PREFIX)/include/Sockets/HttpsSocket.*
@rm -f $(PREFIX)/include/Sockets/EventSocket.*
@rm -f $(PREFIX)/include/Sockets/PoolSocket.*
@rm -f $(PREFIX)/include/Sockets/SocketThread.*
@rm -f $(PREFIX)/include/Sockets/CircularBuffer.*
@rm -f $(PREFIX)/include/Sockets/*Crypt.h
@rm -f $(PREFIX)/include/Sockets/CTcpSocket.h
@rm -f $(PREFIX)/include/Sockets/Min*Socket.h
@rm -f $(PREFIX)/include/Sockets/Min*Handler.h
@rm -f $(PREFIX)/include/Sockets/Uid.h
@mkdir -p $(PREFIX)/bin
install Sockets-config $(PREFIX)/bin
# no binary files, zip will translate lf to cr lf
FILES = *.h *.cpp Makefile Makefile.* Project/*.ds* \
$(HTDOCS)/Sockets/latest_diff.html
install: all
@mkdir -p $(DESTDIR)/$(PREFIX)/lib
cp libSockets.a $(DESTDIR)/$(PREFIX)/lib
@mkdir -p $(DESTDIR)/$(PREFIX)/include/Sockets
cp -a *.h $(DESTDIR)/$(PREFIX)/include/Sockets
@rm -f $(DESTDIR)/$(PREFIX)/include/Sockets/SSLSocket.*
@rm -f $(DESTDIR)/$(PREFIX)/include/Sockets/HttpsGetSocket.*
@rm -f $(DESTDIR)/$(PREFIX)/include/Sockets/HttpsSocket.*
@rm -f $(DESTDIR)/$(PREFIX)/include/Sockets/EventSocket.*
@rm -f $(DESTDIR)/$(PREFIX)/include/Sockets/PoolSocket.*
@rm -f $(DESTDIR)/$(PREFIX)/include/Sockets/SocketThread.*
@rm -f $(DESTDIR)/$(PREFIX)/include/Sockets/CircularBuffer.*
@rm -f $(DESTDIR)/$(PREFIX)/include/Sockets/*Crypt.h
@rm -f $(DESTDIR)/$(PREFIX)/include/Sockets/CTcpSocket.h
@rm -f $(DESTDIR)/$(PREFIX)/include/Sockets/Min*Socket.h
@rm -f $(DESTDIR)/$(PREFIX)/include/Sockets/Min*Handler.h
@rm -f $(DESTDIR)/$(PREFIX)/include/Sockets/Uid.h
@mkdir -p $(DESTDIR)/$(PREFIX)/bin
install Sockets-config $(DESTDIR)/$(PREFIX)/bin
# no binary files, zip will translate lf to cr lf
FILES = *.h *.cpp Makefile Makefile.* Project/*.ds* \

Makefile.version

/usr/src/Sockets-2.3/Makefile.version Tue May 20, 2008./Makefile.version Thu Jun 26, 2008
Line 1 in Makefile.versionLine 1 in Makefile.version
VERSION = 2.3
DIFF_VERSION = 2.2.9a
# Sockets
OBJS = \
VERSION = 2.3.1
DIFF_VERSION = 2.3
# Sockets
OBJS = \

SocketHandler.h

/usr/src/Sockets-2.3/SocketHandler.h Sun Nov 4, 2007./SocketHandler.h Thu Jun 19, 2008
Line 205 in SocketHandler.hLine 205 in SocketHandler.h
std::list<Socket *> m_delete; ///< Sockets to be deleted (failed when Add)
protected:
StdLog *m_stdlog; ///< Registered log class, or NULL
Mutex& m_mutex; ///< Thread safety mutex
bool m_b_use_mutex; ///< Mutex correctly initialized
private:
void CheckList(socket_v&,const std::string&); ///< Used by CheckSanity
/** Remove socket from socket map, used by Socket class. */
void Remove(Socket *);
SOCKET m_maxsock; ///< Highest file descriptor + 1 in active sockets list
fd_set m_rfds; ///< file descriptor set monitored for read events
fd_set m_wfds; ///< file descriptor set monitored for write events
std::list<Socket *> m_delete; ///< Sockets to be deleted (failed when Add)
protected:
/** Remove socket from socket map, used by Socket class. */
void Remove(Socket *);
StdLog *m_stdlog; ///< Registered log class, or NULL
Mutex& m_mutex; ///< Thread safety mutex
bool m_b_use_mutex; ///< Mutex correctly initialized
private:
void CheckList(socket_v&,const std::string&); ///< Used by CheckSanity
SOCKET m_maxsock; ///< Highest file descriptor + 1 in active sockets list
fd_set m_rfds; ///< file descriptor set monitored for read events
fd_set m_wfds; ///< file descriptor set monitored for write events

Utility.cpp

/usr/src/Sockets-2.3/Utility.cpp Wed May 21, 2008./Utility.cpp Wed Jul 2, 2008
Line 40 in Utility.cppLine 40 in Utility.cpp
#include <pthread.h>
#endif
#include <map>
// --- stack
#include <cxxabi.h>
#include <execinfo.h>
#include <dlfcn.h>
// ---
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
Line 1133 in Utility.cppLine 1138 in Utility.cpp
}
const std::string Utility::Stack()
{
#if defined LINUX
#define BFSIZE 255
void *buffer[BFSIZE];
int n = backtrace(buffer, BFSIZE);
char **res = backtrace_symbols(buffer, n);
std::string tmp;
for (int i = 0; i < n; i++)
{
std::string x = res[i];
std::string plus;
std::string addr;
size_t pos = x.find("(");
if (pos != std::string::npos)
{
x = x.substr(pos + 1); // skip executable name
pos = x.find(")");
if (pos != std::string::npos)
{
addr = x.substr(pos + 1);
x = x.substr(0, pos);
}
pos = x.find("+");
if (pos != std::string::npos)
{
plus = x.substr(pos);
x = x.substr(0, pos);
}
}
char zz[1000];
{
size_t sz = 1000;
int status = 0;
abi::__cxa_demangle( x.c_str(), zz, &sz, &status);
if (!status)
{
tmp += zz;
tmp += plus;
tmp += addr;
}
else
{
tmp += res[i];
}
tmp += "\n";
}
// dladdr() test
if (0)
{
Dl_info info;
int n = dladdr(buffer[i], &info);
if (!n)
printf("%d: dladdr() failed\n", i);
else
{
size_t sz = 1000;
int status = 0;
abi::__cxa_demangle( info.dli_sname, zz, &sz, &status);
printf("%d: %s: %s\n", i, info.dli_fname, info.dli_sname);
if (!status)
printf(" %s\n", zz);
}
} // end of dladdr() test
} // for (i)
free(res);
return tmp;
#else
return "Not available";
#endif
}
#ifdef SOCKETS_NAMESPACE
}
#endif

Utility.h

/usr/src/Sockets-2.3/Utility.h Tue May 20, 2008./Utility.h Tue Jul 1, 2008
Line 182 in Utility.hLine 182 in Utility.h
static const char *Logo;
static const std::string Stack();
private:
static std::string m_host; ///< local hostname
static ipaddr_t m_ip; ///< local ip address

socket_include.h

/usr/src/Sockets-2.3/socket_include.h Wed May 21, 2008./socket_include.h Thu Jul 3, 2008
Line 63 in socket_include.hLine 63 in socket_include.h
#ifndef _WIN32
// ----------------------------------------
// common unix includes / defines
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
//#include <netdb.h>
// all typedefs in this file will be declared outside the sockets namespace,
// because some os's will already have one or more of the type defined.

sockets-config.h

/usr/src/Sockets-2.3/sockets-config.h Fri May 9, 2008./sockets-config.h Wed Jul 2, 2008
Line 89 in sockets-config.hLine 89 in sockets-config.h
/* XML classes. */
//#define ENABLE_XML
/* Resolver uses the detach function so either enable both or disable both. */
/* XML classes. */
#define ENABLE_XML
/* Resolver uses the detach function so either enable both or disable both. */
Page, code, and content Copyright (C) 2008 by Anders Hedström