summaryrefslogtreecommitdiff
path: root/lib/psocksxx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/psocksxx')
-rw-r--r--lib/psocksxx/Makefile.am38
-rw-r--r--lib/psocksxx/Makefile.in655
-rw-r--r--lib/psocksxx/iosocks.cpp55
-rw-r--r--lib/psocksxx/iosocks.h99
-rw-r--r--lib/psocksxx/iosockstream.h79
-rw-r--r--lib/psocksxx/isockstream.cpp36
-rw-r--r--lib/psocksxx/isockstream.h58
-rw-r--r--lib/psocksxx/lsockaddr.cpp48
-rw-r--r--lib/psocksxx/lsockaddr.h58
-rw-r--r--lib/psocksxx/lsockstream.cpp65
-rw-r--r--lib/psocksxx/lsockstream.h84
-rw-r--r--lib/psocksxx/nsockaddr.cpp137
-rw-r--r--lib/psocksxx/nsockaddr.h99
-rw-r--r--lib/psocksxx/nsockstream.cpp116
-rw-r--r--lib/psocksxx/nsockstream.h143
-rw-r--r--lib/psocksxx/osockstream.cpp36
-rw-r--r--lib/psocksxx/osockstream.h58
-rw-r--r--lib/psocksxx/sockaddr.h76
-rw-r--r--lib/psocksxx/sockexception.cpp60
-rw-r--r--lib/psocksxx/sockexception.h76
-rw-r--r--lib/psocksxx/sockstreambuf.cpp523
-rw-r--r--lib/psocksxx/sockstreambuf.h345
-rw-r--r--lib/psocksxx/socktimeoutexception.cpp50
-rw-r--r--lib/psocksxx/socktimeoutexception.h67
-rw-r--r--lib/psocksxx/tcpnsockstream.cpp36
-rw-r--r--lib/psocksxx/tcpnsockstream.h56
-rw-r--r--lib/psocksxx/udpnsockstream.cpp36
-rw-r--r--lib/psocksxx/udpnsockstream.h57
28 files changed, 3246 insertions, 0 deletions
diff --git a/lib/psocksxx/Makefile.am b/lib/psocksxx/Makefile.am
new file mode 100644
index 0000000..fb9a26a
--- /dev/null
+++ b/lib/psocksxx/Makefile.am
@@ -0,0 +1,38 @@
+## [psocksxx] lib/psocksxx/
+
+AM_CPPFLAGS = -I$(top_srcdir)/lib
+libpsocksxxincludedir = $(includedir)/psocksxx
+
+lib_LTLIBRARIES = libpsocksxx.la
+libpsocksxx_la_LIBADD =
+libpsocksxx_la_LDFLAGS = -version-info @LIBPSOCKSXX_LT_VERSION@ -no-undefined
+libpsocksxx_la_SOURCES = \
+ sockexception.cpp \
+ socktimeoutexception.cpp \
+ lsockaddr.cpp \
+ nsockaddr.cpp \
+ sockstreambuf.cpp \
+ iosocks.cpp \
+ isockstream.cpp \
+ osockstream.cpp \
+ lsockstream.cpp \
+ nsockstream.cpp \
+ tcpnsockstream.cpp \
+ udpnsockstream.cpp
+
+libpsocksxxinclude_HEADERS = \
+ sockexception.h \
+ socktimeoutexception.h \
+ sockaddr.h \
+ lsockaddr.h \
+ nsockaddr.h \
+ sockstreambuf.h \
+ iosocks.h \
+ isockstream.h \
+ osockstream.h \
+ iosockstream.h \
+ lsockstream.h \
+ nsockstream.h \
+ tcpnsockstream.h \
+ udpnsockstream.h
+
diff --git a/lib/psocksxx/Makefile.in b/lib/psocksxx/Makefile.in
new file mode 100644
index 0000000..8ec1b54
--- /dev/null
+++ b/lib/psocksxx/Makefile.in
@@ -0,0 +1,655 @@
+# Makefile.in generated by automake 1.12.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2012 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__make_dryrun = \
+ { \
+ am__dry=no; \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
+ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+ *) \
+ for am__flg in $$MAKEFLAGS; do \
+ case $$am__flg in \
+ *=*|--*) ;; \
+ *n*) am__dry=yes; break;; \
+ esac; \
+ done;; \
+ esac; \
+ test $$am__dry = yes; \
+ }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = lib/psocksxx
+DIST_COMMON = $(libpsocksxxinclude_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in $(top_srcdir)/aux-build/depcomp
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/aux-build/m4/libtool.m4 \
+ $(top_srcdir)/aux-build/m4/ltoptions.m4 \
+ $(top_srcdir)/aux-build/m4/ltsugar.m4 \
+ $(top_srcdir)/aux-build/m4/ltversion.m4 \
+ $(top_srcdir)/aux-build/m4/lt~obsolete.m4 \
+ $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(libdir)" \
+ "$(DESTDIR)$(libpsocksxxincludedir)"
+LTLIBRARIES = $(lib_LTLIBRARIES)
+libpsocksxx_la_DEPENDENCIES =
+am_libpsocksxx_la_OBJECTS = sockexception.lo socktimeoutexception.lo \
+ lsockaddr.lo nsockaddr.lo sockstreambuf.lo iosocks.lo \
+ isockstream.lo osockstream.lo lsockstream.lo nsockstream.lo \
+ tcpnsockstream.lo udpnsockstream.lo
+libpsocksxx_la_OBJECTS = $(am_libpsocksxx_la_OBJECTS)
+libpsocksxx_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(libpsocksxx_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/aux-build/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libpsocksxx_la_SOURCES)
+DIST_SOURCES = $(libpsocksxx_la_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+HEADERS = $(libpsocksxxinclude_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@
+CPPUNIT_CONFIG = @CPPUNIT_CONFIG@
+CPPUNIT_LIBS = @CPPUNIT_LIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DOXYGEN = @DOXYGEN@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBPSOCKSXX_LT_VERSION = @LIBPSOCKSXX_LT_VERSION@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/lib
+libpsocksxxincludedir = $(includedir)/psocksxx
+lib_LTLIBRARIES = libpsocksxx.la
+libpsocksxx_la_LIBADD =
+libpsocksxx_la_LDFLAGS = -version-info @LIBPSOCKSXX_LT_VERSION@ -no-undefined
+libpsocksxx_la_SOURCES = \
+ sockexception.cpp \
+ socktimeoutexception.cpp \
+ lsockaddr.cpp \
+ nsockaddr.cpp \
+ sockstreambuf.cpp \
+ iosocks.cpp \
+ isockstream.cpp \
+ osockstream.cpp \
+ lsockstream.cpp \
+ nsockstream.cpp \
+ tcpnsockstream.cpp \
+ udpnsockstream.cpp
+
+libpsocksxxinclude_HEADERS = \
+ sockexception.h \
+ socktimeoutexception.h \
+ sockaddr.h \
+ lsockaddr.h \
+ nsockaddr.h \
+ sockstreambuf.h \
+ iosocks.h \
+ isockstream.h \
+ osockstream.h \
+ iosockstream.h \
+ lsockstream.h \
+ nsockstream.h \
+ tcpnsockstream.h \
+ udpnsockstream.h
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/psocksxx/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign lib/psocksxx/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+ }
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+ done
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+libpsocksxx.la: $(libpsocksxx_la_OBJECTS) $(libpsocksxx_la_DEPENDENCIES) $(EXTRA_libpsocksxx_la_DEPENDENCIES)
+ $(libpsocksxx_la_LINK) -rpath $(libdir) $(libpsocksxx_la_OBJECTS) $(libpsocksxx_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iosocks.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isockstream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsockaddr.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsockstream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nsockaddr.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nsockstream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osockstream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sockexception.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sockstreambuf.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socktimeoutexception.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpnsockstream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/udpnsockstream.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-libpsocksxxincludeHEADERS: $(libpsocksxxinclude_HEADERS)
+ @$(NORMAL_INSTALL)
+ @list='$(libpsocksxxinclude_HEADERS)'; test -n "$(libpsocksxxincludedir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(libpsocksxxincludedir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(libpsocksxxincludedir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libpsocksxxincludedir)'"; \
+ $(INSTALL_HEADER) $$files "$(DESTDIR)$(libpsocksxxincludedir)" || exit $$?; \
+ done
+
+uninstall-libpsocksxxincludeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(libpsocksxxinclude_HEADERS)'; test -n "$(libpsocksxxincludedir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(libpsocksxxincludedir)'; $(am__uninstall_files_from_dir)
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+cscopelist: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libpsocksxxincludedir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-libpsocksxxincludeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-libLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-libLTLIBRARIES \
+ uninstall-libpsocksxxincludeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libLTLIBRARIES clean-libtool cscopelist ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am \
+ install-libLTLIBRARIES install-libpsocksxxincludeHEADERS \
+ install-man install-pdf install-pdf-am install-ps \
+ install-ps-am install-strip installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+ uninstall-am uninstall-libLTLIBRARIES \
+ uninstall-libpsocksxxincludeHEADERS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/lib/psocksxx/iosocks.cpp b/lib/psocksxx/iosocks.cpp
new file mode 100644
index 0000000..33410fd
--- /dev/null
+++ b/lib/psocksxx/iosocks.cpp
@@ -0,0 +1,55 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include "iosocks.h"
+
+
+namespace psocksxx {
+
+ bool iosocks::timedout() const throw() {
+
+ // socket stream buffer
+ sockstreambuf * ssb = (sockstreambuf *) rdbuf();
+
+ return ssb->timedout();
+
+ }
+
+
+ const timeval * iosocks::timeout( time_t sec, suseconds_t usec ) throw() {
+
+ // socket stream buffer
+ sockstreambuf * ssb = (sockstreambuf *) rdbuf();
+
+ return ssb->timeout( sec, usec );
+
+ }
+
+
+ void * iosocks::clear_timeout() throw() {
+
+ // socket stream buffer
+ sockstreambuf * ssb = (sockstreambuf *) rdbuf();
+
+ return ssb->clear_timeout();
+
+ }
+
+} /* end of namespace psocksxx */
+
diff --git a/lib/psocksxx/iosocks.h b/lib/psocksxx/iosocks.h
new file mode 100644
index 0000000..293a288
--- /dev/null
+++ b/lib/psocksxx/iosocks.h
@@ -0,0 +1,99 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#ifndef PSOCKSXX_IOSOCKS_H
+#define PSOCKSXX_IOSOCKS_H
+
+#include <psocksxx/sockstreambuf.h>
+
+#include <ios>
+
+
+namespace psocksxx {
+
+ /**
+ * @brief base class for socket stream controller classes
+ *
+ * This class holds the common methods for socket stream controller
+ * classes.
+ */
+ class iosocks : public virtual std::ios {
+ public:
+
+ /**
+ * @brief destructor
+ *
+ * Does nothing.
+ *
+ */
+ virtual ~iosocks() throw() { };
+
+ /**
+ * @brief get the timed-out status flag value
+ * @return boolean @c true if timed-out flag is set or @c false
+ * otherwise.
+ *
+ * Returns the timed-out status for the associated socket stream
+ * buffer.
+ *
+ */
+ bool timedout() const throw();
+
+ /**
+ * @brief set the timeout value for stream communications
+ * @param sec seconds
+ * @param usec microseconds
+ * @return a reference to the internal timeout structure
+ *
+ * Wrapper method for sockstreambuf::timeout() to set the
+ * timeout value for stream communications.
+ *
+ * @see sockstreambuf::timeout()
+ *
+ */
+ const timeval * timeout( time_t sec, suseconds_t usec ) throw();
+
+ /**
+ * @brief clear the timeout value
+ * @return a reference to the internal timeout structure which will
+ * always be a null-pointer (@c 0) after clearing the timeout
+ *
+ * This will clear any timeout values set for this stream using
+ * timeout().
+ *
+ */
+ void * clear_timeout() throw();
+
+ protected:
+
+ /**
+ * @brief empty default constructor
+ *
+ * Empty default constructor so that derived classes through virtual
+ * inheritance does not have to call the constructor.
+ *
+ */
+ iosocks() throw() { }
+
+ };
+
+} /* end of namespace psocksxx */
+
+#endif /* !PSOCKSXX_IOSOCKS_H */
+
diff --git a/lib/psocksxx/iosockstream.h b/lib/psocksxx/iosockstream.h
new file mode 100644
index 0000000..2b2b0bb
--- /dev/null
+++ b/lib/psocksxx/iosockstream.h
@@ -0,0 +1,79 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#ifndef PSOCKSXX_IOSOCKSTREAM_H
+#define PSOCKSXX_IOSOCKSTREAM_H
+
+#include <psocksxx/isockstream.h>
+#include <psocksxx/osockstream.h>
+
+
+namespace psocksxx {
+
+ /**
+ * @brief Input and Output controller class for socket streams
+ *
+ * This merges the two input and output controller
+ * classes to create a single interface for controlling
+ * both input and output socket streams.
+ *
+ */
+ class iosockstream :
+ public isockstream,
+ public osockstream {
+
+ public:
+
+ /**
+ * @brief constructor
+ * @param ssb socket stream buffer
+ *
+ * This constructor simply initialises the parent
+ * classes with the passed in socket stream buffer
+ */
+ iosockstream( sockstreambuf * ssb ) throw() :
+ isockstream( ssb ), osockstream( ssb ) {
+ // constructor
+ }
+
+ /**
+ * @brief destructor
+ */
+ virtual ~iosockstream() throw() {
+ // destructor
+ }
+
+ /**
+ * @brief get the timed-out status for this stream
+ * @return boolean @c true if timed-out flag is set or @c false
+ * otherwise.
+ *
+ * Returns the timed-out status.
+ *
+ */
+ bool timedout() const throw() {
+ return ( isockstream::timedout() || osockstream::timedout() );
+ }
+
+ };
+
+} /* end of namespace psocksxx */
+
+#endif /* !PSOCKSXX_IOSOCKSTREAM_H */
+
diff --git a/lib/psocksxx/isockstream.cpp b/lib/psocksxx/isockstream.cpp
new file mode 100644
index 0000000..a6502b9
--- /dev/null
+++ b/lib/psocksxx/isockstream.cpp
@@ -0,0 +1,36 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include "isockstream.h"
+
+
+namespace psocksxx {
+
+ isockstream::isockstream( sockstreambuf * ssb ) throw() :
+ std::istream( ssb ) {
+ // constructor
+ }
+
+
+ isockstream::~isockstream() throw() {
+ // destructor
+ }
+
+} /* end of namespace psocksxx */
+
diff --git a/lib/psocksxx/isockstream.h b/lib/psocksxx/isockstream.h
new file mode 100644
index 0000000..2ed0d65
--- /dev/null
+++ b/lib/psocksxx/isockstream.h
@@ -0,0 +1,58 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#ifndef PSOCKSXX_ISOCKSTREAM_H
+#define PSOCKSXX_ISOCKSTREAM_H
+
+#include <psocksxx/iosocks.h>
+
+#include <istream>
+
+
+namespace psocksxx {
+
+ /**
+ * @brief Input controller class for socket streams
+ *
+ * This class acts as an interface for getting inputs
+ * from a psocksxx::sockstreambuf class.
+ */
+ class isockstream :
+ public virtual iosocks,
+ public std::istream {
+
+ public:
+
+ /**
+ * @brief constructor
+ * @param ssb socket stream buffer
+ *
+ * Create an input socket stream controller instance.
+ *
+ */
+ isockstream( sockstreambuf * ssb ) throw();
+
+ virtual ~isockstream() throw(); //!< destructor
+
+ };
+
+} /* end of namespace psocksxx */
+
+#endif /* !PSOCKSXX_ISOCKSTREAM_H */
+
diff --git a/lib/psocksxx/lsockaddr.cpp b/lib/psocksxx/lsockaddr.cpp
new file mode 100644
index 0000000..6e854e2
--- /dev/null
+++ b/lib/psocksxx/lsockaddr.cpp
@@ -0,0 +1,48 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include "lsockaddr.h"
+
+#include <cstring>
+
+
+namespace psocksxx {
+
+ lsockaddr::lsockaddr( const char * path ) throw() {
+
+ // set the socket address family
+ sun_family = sockaddr::af_local;
+
+ // set the socket path
+ strcpy( sun_path, path );
+
+ }
+
+
+ socklen_t lsockaddr::size() const throw() {
+ return sizeof( sockaddr_un );
+ }
+
+
+ ::sockaddr * lsockaddr::psockaddr() const throw() {
+ return (::sockaddr *) (sockaddr_un *) this;
+ }
+
+} /* end of namespace psocksxx */
+
diff --git a/lib/psocksxx/lsockaddr.h b/lib/psocksxx/lsockaddr.h
new file mode 100644
index 0000000..a66804f
--- /dev/null
+++ b/lib/psocksxx/lsockaddr.h
@@ -0,0 +1,58 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#ifndef PSOCKSXX_LSOCKADDR_H
+#define PSOCKSXX_LSOCKADDR_H
+
+#include <psocksxx/sockaddr.h>
+#include <sys/un.h>
+
+
+namespace psocksxx {
+
+ /**
+ * @brief Socket address class for local sockets
+ *
+ * This class holds the socket addressing structure for local
+ * (unix) socket communications.
+ *
+ */
+ class lsockaddr : public sockaddr, public sockaddr_un {
+ public:
+
+ /**
+ * @brief constructor
+ * @param path local socket address file path
+ *
+ * Create a local socket address instance with the given file
+ * path as the socket address.
+ *
+ */
+ lsockaddr( const char * path ) throw();
+
+ // abstract method implementations
+ socklen_t size() const throw();
+ ::sockaddr* psockaddr() const throw();
+
+ };
+
+} /* end of namespace psocksxx */
+
+#endif /* !PSOCKSXX_LSOCKADDR_H */
+
diff --git a/lib/psocksxx/lsockstream.cpp b/lib/psocksxx/lsockstream.cpp
new file mode 100644
index 0000000..bfe3fed
--- /dev/null
+++ b/lib/psocksxx/lsockstream.cpp
@@ -0,0 +1,65 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include "lsockstream.h"
+
+
+namespace psocksxx {
+
+ lsockstream::lsockstream() throw( sockexception ) : iosockstream( 0 ) {
+
+ // socket stream buffer instance
+ sockstreambuf * ssb = new sockstreambuf();
+
+ // open local socket
+ ssb->open( sockstreambuf::pf_local, sockstreambuf::sock_stream, sockstreambuf::proto_unspec );
+
+ // update I/O buffer
+ iosockstream::init( ssb );
+
+ }
+
+
+ lsockstream::~lsockstream() throw() {
+
+ // cleanup
+ delete iosockstream::rdbuf();
+
+ }
+
+
+ void lsockstream::connect( const char * path ) throw( sockexception, socktimeoutexception ) {
+
+ lsockaddr saddr( path );
+ sockstreambuf * ssb = (sockstreambuf *) rdbuf();
+
+ ssb->connect( &saddr );
+
+ }
+
+
+ void lsockstream::connect( const lsockaddr * saddr ) throw( sockexception, socktimeoutexception ) {
+
+ sockstreambuf * ssb = (sockstreambuf *) rdbuf();
+ ssb->connect( saddr );
+
+ }
+
+} /* end of namespace psocksxx */
+
diff --git a/lib/psocksxx/lsockstream.h b/lib/psocksxx/lsockstream.h
new file mode 100644
index 0000000..4aa2722
--- /dev/null
+++ b/lib/psocksxx/lsockstream.h
@@ -0,0 +1,84 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#ifndef PSOCKSXX_LSOCKSTREAM_H
+#define PSOCKSXX_LSOCKSTREAM_H
+
+#include <psocksxx/iosockstream.h>
+#include <psocksxx/lsockaddr.h>
+
+
+namespace psocksxx {
+
+ /**
+ * @brief Local (unix) socket controller class
+ *
+ * This class acts as a controller for communicating through a
+ * local (unix) socket and uses an instance of psocksxx::sockstreambuf
+ * as the underlying / associated sequence.
+ */
+ class lsockstream : public iosockstream {
+ public:
+
+ /**
+ * @brief constructor
+ * @throw psocksxx::sockexception socket exception
+ *
+ * Initialise a local (unix) communication stream.
+ *
+ */
+ lsockstream() throw( sockexception );
+
+ /**
+ * @brief destructor
+ */
+ virtual ~lsockstream() throw();
+
+ /**
+ * @brief connect to a local socket
+ * @param path local socket path
+ * @throw psocksxx::sockexception socket exception
+ * @throw psocksxx::socktimeoutexception connection timeout
+ * exception
+ *
+ * Connect a to local socket at the given path. It is assumed
+ * that the socket is ready to accept connections.
+ *
+ */
+ void connect( const char * path ) throw( sockexception, socktimeoutexception );
+
+ /**
+ * @brief connect to a local socket
+ * @param saddr local socket address instance
+ * @throw psocksxx::sockexception socket exception
+ * @throw psocksxx::socktimeoutexception connection timeout
+ * exception
+ *
+ * Connect to a local socket using the passed in socket address
+ * object.
+ *
+ */
+ void connect( const lsockaddr * saddr ) throw( sockexception, socktimeoutexception );
+
+ };
+
+} /* end of namespace psocksxx */
+
+#endif /* !PSOCKSXX_LSOCKSTREAM_H */
+
diff --git a/lib/psocksxx/nsockaddr.cpp b/lib/psocksxx/nsockaddr.cpp
new file mode 100644
index 0000000..08d9969
--- /dev/null
+++ b/lib/psocksxx/nsockaddr.cpp
@@ -0,0 +1,137 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include "nsockaddr.h"
+#include "sockstreambuf.h"
+
+#include <netdb.h>
+#include <cstring>
+
+
+namespace psocksxx {
+
+ nsockaddr::nsockaddr( const char * node, unsigned short port ) throw( sockexception ) {
+
+ // set the socket address family
+ sin_family = sockaddr::af_inet;
+
+ // set the port
+ sin_port = htons( port );
+
+ // set the address
+ sin_addr.s_addr = resolve_node( node );
+
+ // zero out internals
+ memset( sin_zero, 0, sizeof( sin_zero ) );
+
+ }
+
+
+ nsockaddr::nsockaddr( unsigned short port ) throw() {
+
+ // set the socket address family
+ sin_family = sockaddr::af_inet;
+
+ // set the port
+ sin_port = htons( port );
+
+ // set the address
+ sin_addr.s_addr = INADDR_ANY;
+
+ // zero out internals
+ memset( sin_zero, 0, sizeof( sin_zero ) );
+
+ }
+
+
+ nsockaddr::nsockaddr( const char * node, const char * service ) throw( sockexception ) {
+
+ int status;
+ addrinfo hints;
+ addrinfo * result;
+ sockaddr_in * sinaddr;
+
+ // empty the hints structure
+ memset( &hints, 0, sizeof( hints ) );
+
+ // setup hints
+ hints.ai_family = sockaddr::af_inet;
+ hints.ai_socktype = sockstreambuf::sock_stream;
+
+ // translate node and service into a network address
+ if ( ( status = ( getaddrinfo( node, service, &hints, &result ) ) ) != 0 ) {
+ throw sockexception( gai_strerror( status ) );
+ }
+
+ // grab the address info we need
+ sinaddr = (sockaddr_in *) result->ai_addr;
+ sin_family = sockaddr::af_inet;
+ sin_addr = sinaddr->sin_addr;
+ sin_port = sinaddr->sin_port;
+
+ // zero out internals
+ memset( sin_zero, 0, sizeof( sin_zero ) );
+
+ // cleanup
+ freeaddrinfo( result );
+
+ }
+
+
+ in_addr_t nsockaddr::resolve_node( const char * node ) throw( sockexception ) {
+
+ int status;
+ addrinfo hints;
+ addrinfo * result;
+ in_addr_t in_addr;
+
+ // empty the hints structure
+ memset( &hints, 0, sizeof( hints ) );
+
+ // setup hints
+ hints.ai_family = sockaddr::af_inet;
+ hints.ai_socktype = sockstreambuf::sock_stream;
+
+ // resolve node
+ if ( ( status = ( getaddrinfo( node, 0, &hints, &result ) ) ) != 0 ) {
+ throw sockexception( gai_strerror( status ) );
+ }
+
+ // grab the address info we need
+ in_addr = ( (sockaddr_in *) result->ai_addr )->sin_addr.s_addr;
+
+ // cleanup
+ freeaddrinfo( result );
+
+ return in_addr;
+
+ }
+
+
+ socklen_t nsockaddr::size() const throw() {
+ return sizeof( sockaddr_in );
+ }
+
+
+ ::sockaddr * nsockaddr::psockaddr() const throw() {
+ return (::sockaddr *) (sockaddr_in *) this;
+ }
+
+} /* end of namespace psocksxx */
+
diff --git a/lib/psocksxx/nsockaddr.h b/lib/psocksxx/nsockaddr.h
new file mode 100644
index 0000000..d8f7f75
--- /dev/null
+++ b/lib/psocksxx/nsockaddr.h
@@ -0,0 +1,99 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#ifndef PSOCKSXX_NSOCKADDR_H
+#define PSOCKSXX_NSOCKADDR_H
+
+#include <psocksxx/sockaddr.h>
+#include <psocksxx/sockexception.h>
+#include <netinet/in.h>
+
+
+namespace psocksxx {
+
+ /**
+ * @brief Socket address class for IPv4 addresses
+ *
+ * This class holds the socket addressing structure for IPv4
+ * socket communications.
+ *
+ */
+ class nsockaddr : public sockaddr, public sockaddr_in {
+ public:
+
+ /**
+ * @brief constructor
+ * @param node node (host name or IP)
+ * @param port port number
+ * @throw psocksxx::sockexception socket exception
+ *
+ * Create a IPv4 socket address instance with the give node
+ * and port information.
+ *
+ */
+ nsockaddr( const char * node, unsigned short port ) throw( sockexception );
+
+ /**
+ * @brief constructor
+ * @param port port number
+ *
+ * Create a IPv4 socket address instance with the given port
+ * and the node (host/IP) will be any available interface on
+ * the host computer.
+ *
+ */
+ nsockaddr( unsigned short port ) throw();
+
+ /**
+ * @brief constructor
+ * @param node node (host name or IP)
+ * @param service port number of the service name (e.g. "http")
+ * @throw psocksxx::sockexception socket exception
+ *
+ * Create a IPv4 socket address instance with the give node
+ * and service information.
+ *
+ */
+ nsockaddr( const char * node, const char * service ) throw( sockexception );
+
+ // abstract method implementations
+ socklen_t size() const throw();
+ ::sockaddr* psockaddr() const throw();
+
+
+ protected:
+
+ /**
+ * @brief convert a node name to a IPv4 address
+ * @param node node (host name or IP)
+ * @throw psocksxx::sockexception socket exception
+ * @return IPv4 address in network byte order
+ *
+ * Helper function to convert a node name into a IPv4 network
+ * address.
+ *
+ */
+ in_addr_t resolve_node( const char * node ) throw( sockexception );
+
+ };
+
+} /* end of namespace psockxx */
+
+#endif /* !PSOCKSXX_NSOCKADDR_H */
+
diff --git a/lib/psocksxx/nsockstream.cpp b/lib/psocksxx/nsockstream.cpp
new file mode 100644
index 0000000..b3ee9cc
--- /dev/null
+++ b/lib/psocksxx/nsockstream.cpp
@@ -0,0 +1,116 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include "nsockstream.h"
+
+
+namespace psocksxx {
+
+ nsockstream::nsockstream( sockstreambuf::socket_type_t type, sockstreambuf::socket_protocol_t proto )
+ throw ( sockexception ) : iosockstream( 0 ) {
+
+ // socket stream buffer instance
+ sockstreambuf * ssb = new sockstreambuf();
+
+ // open the socket communication
+ ssb->open( sockstreambuf::pf_inet, type, proto );
+
+ // update I/O buffer
+ iosockstream::init( ssb );
+
+ }
+
+
+ nsockstream::nsockstream( sockstreambuf * ssb ) throw() : iosockstream( ssb ) {
+
+ }
+
+
+ nsockstream::~nsockstream() throw() {
+
+ // cleanup
+ delete iosockstream::rdbuf();
+
+ }
+
+
+ void nsockstream::connect( const nsockaddr * saddr ) throw( sockexception, socktimeoutexception ) {
+
+ // socket stream buffer
+ sockstreambuf * ssb = (sockstreambuf *) rdbuf();
+
+ // connect
+ ssb->connect( saddr );
+
+ }
+
+
+ void nsockstream::connect( const char * node, unsigned int port ) throw( sockexception, socktimeoutexception ) {
+
+ // network address
+ nsockaddr naddr( node, port );
+
+ // connect
+ connect( &naddr );
+
+ }
+
+
+ void nsockstream::bind( const nsockaddr * saddr, bool reuse_addr ) throw( sockexception ) {
+
+ // socket stream buffer
+ sockstreambuf * ssb = (sockstreambuf *) rdbuf();
+
+ // bind
+ ssb->bind( saddr, reuse_addr );
+
+ }
+
+
+ void nsockstream::listen( int backlog ) throw( sockexception ) {
+
+ // socket stream buffer
+ sockstreambuf * ssb = (sockstreambuf *) rdbuf();
+
+ if ( backlog == 0 ) {
+ ssb->listen();
+ } else {
+ ssb->listen( backlog );
+ }
+
+ }
+
+
+ nsockstream * nsockstream::accept() throw( sockexception ) {
+
+ // socket stream buffers
+ sockstreambuf * ssb = (sockstreambuf *) rdbuf();
+ sockstreambuf * cl_ssb;
+
+ // accept
+ sockstreambuf::socket_t cl_sock = ssb->accept();
+ cl_ssb = new sockstreambuf( cl_sock );
+
+ // return
+ return new nsockstream( cl_ssb );
+
+ }
+
+} /* end of namespace psocksxx */
+
diff --git a/lib/psocksxx/nsockstream.h b/lib/psocksxx/nsockstream.h
new file mode 100644
index 0000000..9d7e5a2
--- /dev/null
+++ b/lib/psocksxx/nsockstream.h
@@ -0,0 +1,143 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#ifndef PSOCKSXX_NSOCKSTREAM_H
+#define PSOCKSXX_NSOCKSTREAM_H
+
+#include <psocksxx/iosockstream.h>
+#include <psocksxx/nsockaddr.h>
+
+
+namespace psocksxx {
+
+ /**
+ * @brief Network (IPv4) controller class
+ *
+ * This is the base class for network (IP version 4)
+ * communications streams.
+ *
+ */
+ class nsockstream : public iosockstream {
+ public:
+
+ /**
+ * @brief constructor
+ * @param type socket communications type
+ * @param proto socket communications protocol
+ * @throw psocksxx::sockexception socket exception
+ *
+ * Open a network (IPv4) communications stream with the
+ * passed in type and protocol.
+ */
+ nsockstream( sockstreambuf::socket_type_t type, sockstreambuf::socket_protocol_t proto ) throw( sockexception );
+
+ /**
+ * @brief constructor
+ * @param ssb initialised socket stream buffer instance
+ *
+ * Initialise a network socket stream by using the passed in
+ * socket stream buffer, @c ssb, as the associated sequence
+ * which is assumed to be initialised with the correct type
+ * and protocol. The class destructor will delete the psocksxx::sockstreambuf
+ * instance pointed by @c ssb.
+ *
+ */
+ nsockstream( sockstreambuf * ssb ) throw();
+
+ /**
+ * @brief destructor
+ */
+ virtual ~nsockstream() throw();
+
+ /**
+ * @brief connect to a network address
+ * @param saddr destination address information
+ * @throw psocksxx::sockexception socket exception
+ * @throw psocksxx::socktimeoutexception connection timeout
+ * exception
+ *
+ * Connect to a IPv4 communication end point making this stream
+ * ready for I/O.
+ *
+ */
+ void connect( const nsockaddr * saddr ) throw( sockexception, socktimeoutexception );
+
+ /**
+ * @brief connect to a network address
+ * @param node node (host name or IP)
+ * @param port port number
+ * @throw psocksxx::sockexception socket exception
+ * @throw psocksxx::socktimeoutexception connection timeout
+ * exception
+ *
+ * Connect to a IPv4 communication end point making this stream
+ * ready for I/O.
+ *
+ */
+ void connect( const char * node, unsigned int port ) throw( sockexception, socktimeoutexception );
+
+ /**
+ * @brief bind the stream to a network address
+ * @param saddr address information to bind to
+ * @param reuse_addr allow address to be re-used
+ * @throw psocksxx::sockexception socket exception
+ *
+ * This binds the network socket stream to the specified network
+ * address. If you want to try to bind to any socket that is not
+ * actively listening (e.g. TIME_WAIT) then set the @c reuse_addr
+ * parameter to be @c true.
+ *
+ */
+ void bind( const nsockaddr * saddr, bool reuse_addr = false ) throw( sockexception );
+
+ /**
+ * @brief make this stream passive and ready to accept connections
+ * @param backlog maximum length of the queue for pending connections
+ * and if this value is 0 (default) then it assumes
+ * system default
+ *
+ * @throw psocksxx::sockexception socket exception
+ *
+ * Make this network stream passive and ready to accept connections.
+ * Before calling this method the stream must be bound to a
+ * network address using the bind() method.
+ *
+ */
+ void listen( int backlog = 0 ) throw( sockexception );
+
+ /**
+ * @brief accept a connection on a listening (passive) stream
+ * @throw psocksxx::sockexception socket exception
+ * @return a new stream instance for the accepted connection
+ *
+ * This method will accept an incoming connection on a listening
+ * stream and return a newly created stream instance that can
+ * be used to communicate with the accepted client connection.
+ * Note that the returned stream instance must be deleted by the
+ * caller.
+ *
+ */
+ nsockstream * accept() throw( sockexception );
+
+ };
+
+} /* end of namespace psocksxx */
+
+#endif /* !PSOCKSXX_NSOCKSTEAM_H */
+
diff --git a/lib/psocksxx/osockstream.cpp b/lib/psocksxx/osockstream.cpp
new file mode 100644
index 0000000..1e7eabb
--- /dev/null
+++ b/lib/psocksxx/osockstream.cpp
@@ -0,0 +1,36 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include "osockstream.h"
+
+
+namespace psocksxx {
+
+ osockstream::osockstream( sockstreambuf * ssb ) throw() :
+ std::ostream( ssb ) {
+ // constructor
+ }
+
+
+ osockstream::~osockstream() throw() {
+ // destructor
+ }
+
+} /* end of namespace psocksxx */
+
diff --git a/lib/psocksxx/osockstream.h b/lib/psocksxx/osockstream.h
new file mode 100644
index 0000000..f245cee
--- /dev/null
+++ b/lib/psocksxx/osockstream.h
@@ -0,0 +1,58 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#ifndef PSOCKSXX_OSOCKSTREAM_H
+#define PSOCKSXX_OSOCKSTREAM_H
+
+#include <psocksxx/iosocks.h>
+
+#include <ostream>
+
+
+namespace psocksxx {
+
+ /**
+ * @brief Output controller class for socket streams
+ *
+ * This class acts as an interface for sendding outputs
+ * to a psocksxx::sockstreambuf class
+ */
+ class osockstream :
+ public virtual iosocks,
+ public std::ostream {
+
+ public:
+
+ /**
+ * @brief constructor
+ * @param ssb socket stream buffer
+ *
+ * Create and output socket stream controller instance
+ *
+ */
+ osockstream( sockstreambuf * ssb ) throw();
+
+ virtual ~osockstream() throw(); //!< destructor
+
+ };
+
+} /* end of namespace psocksxx */
+
+#endif /* !PSOCKS_OSOCKSTREAM_H */
+
diff --git a/lib/psocksxx/sockaddr.h b/lib/psocksxx/sockaddr.h
new file mode 100644
index 0000000..bfe8af7
--- /dev/null
+++ b/lib/psocksxx/sockaddr.h
@@ -0,0 +1,76 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#ifndef PSOCKSXX_SOCKADDR_H
+#define PSOCKSXX_SOCKADDR_H
+
+#include <sys/socket.h>
+
+
+namespace psocksxx {
+
+ /**
+ * @brief Socket address base class
+ *
+ * This abstract class acts as an interface for accessing derived
+ * socket address structures.
+ *
+ */
+ class sockaddr {
+ public:
+
+ /** socket address types definition */
+ enum address_t {
+ af_unspec = AF_UNSPEC, /*! unspecified */
+ af_local = AF_LOCAL, /*! local addresses */
+ af_inet = AF_INET /*! network addresses */
+ };
+
+
+ /**
+ * @brief destructor
+ */
+ virtual ~sockaddr() { };
+
+ /**
+ * @brief get POSIX socket address size
+ * @return POSIX address size
+ *
+ * Helper function to get the size of the related POSIX socket
+ * address.
+ *
+ */
+ virtual socklen_t size() const throw() =0;
+
+ /**
+ * @brief get a POSIX socket address structure
+ * @return POSIX socket address structure
+ *
+ * Helper function to get a pointer to the POSIX socket
+ * address structure relating to this socket address instance.
+ *
+ */
+ virtual ::sockaddr * psockaddr() const throw() =0;
+
+ };
+
+} /* end of namespace psocksxx */
+
+#endif /* !PSOCKSXX_SOCKADDR_H */
+
diff --git a/lib/psocksxx/sockexception.cpp b/lib/psocksxx/sockexception.cpp
new file mode 100644
index 0000000..30affc7
--- /dev/null
+++ b/lib/psocksxx/sockexception.cpp
@@ -0,0 +1,60 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include "sockexception.h"
+
+#include <cerrno>
+#include <cstring>
+
+
+namespace psocksxx {
+
+ sockexception::sockexception( const char * message ) throw() {
+
+ // copy system error
+ _errno = errno;
+ _sys_msg = strerror( _errno );
+
+ // sanity check
+ if ( message == 0 ) {
+
+ // use system error message if no user message is passed in
+ _message = _sys_msg;
+
+ } else {
+
+ // use the user message
+ _message = message;
+
+ }
+
+ }
+
+
+ sockexception::~sockexception() throw() {
+
+ }
+
+
+ const char * sockexception::what() const throw() {
+ return _message.c_str();
+ }
+
+} /* end of namespace psocksxx */
+
diff --git a/lib/psocksxx/sockexception.h b/lib/psocksxx/sockexception.h
new file mode 100644
index 0000000..95c50de
--- /dev/null
+++ b/lib/psocksxx/sockexception.h
@@ -0,0 +1,76 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#ifndef PSOCKSXX_SOCKEXCEPTION_H
+#define PSOCKSXX_SOCKEXCEPTION_H
+
+#include <exception>
+#include <cstddef>
+#include <string>
+
+
+namespace psocksxx {
+
+ /**
+ * @brief Socket exception
+ *
+ * This is the base class for all socket exceptions.
+ */
+ class sockexception : public std::exception {
+ public:
+ /**
+ * @brief constructor
+ *
+ * Create an instance with the passed in error message.
+ * If a message is not passed in or is equal to @c 0 then
+ * the system error message is used.
+ *
+ * @param message (optional) user error message
+ */
+ sockexception( const char * message = 0 ) throw();
+
+ virtual ~sockexception() throw(); //!< destructor
+
+ /**
+ * @brief Returns exception message
+ *
+ * Returns a C-Style character string describing the
+ * exception.
+ *
+ * @return exception message
+ * @sa sockexception() constructor
+ */
+ const char * what() const throw();
+
+ protected:
+ /** user exception message */
+ std::string _message;
+
+ /** system error number */
+ int _errno;
+
+ /** system error message */
+ std::string _sys_msg;
+
+ };
+
+} /* end of namespace psocksxx */
+
+#endif /* !PSOCKSXX_SOCKEXCEPTION_H */
+
diff --git a/lib/psocksxx/sockstreambuf.cpp b/lib/psocksxx/sockstreambuf.cpp
new file mode 100644
index 0000000..c0a0c81
--- /dev/null
+++ b/lib/psocksxx/sockstreambuf.cpp
@@ -0,0 +1,523 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include "sockstreambuf.h"
+
+#include <fcntl.h>
+#include <cstring>
+
+// Mac OSX does not define MSG_NOSIGNAL
+#ifndef MSG_NOSIGNAL
+#define MSG_NOSIGNAL 0
+#endif
+
+
+namespace psocksxx {
+
+ sockstreambuf::sockstreambuf() throw() :
+ _socket( -1 ), _bufsize( SOCKSTREAMBUF_SIZE ),
+ _putbacksize( SOCKSTREAMBUF_PUTBACK_SIZE ) {
+
+ // initialise defaults
+ init_defaults();
+
+ // initialise internal buffers
+ init_buffers();
+
+ }
+
+
+ sockstreambuf::sockstreambuf( socket_t socket ) throw() :
+ _bufsize( SOCKSTREAMBUF_SIZE ),
+ _putbacksize( SOCKSTREAMBUF_PUTBACK_SIZE ) {
+
+ // update local copy of the socket data
+ _socket = socket;
+
+ // initialise defaults
+ init_defaults();
+
+ // initialise internal buffers
+ init_buffers();
+
+ }
+
+
+ sockstreambuf::~sockstreambuf() {
+
+ // close any open sockets
+ close();
+
+ // cleanup buffers
+ cleanup_buffers();
+
+ // cleanup timeout
+ if ( _timeout != 0 ) {
+ delete _timeout;
+ }
+
+ }
+
+
+ void sockstreambuf::init_defaults() throw() {
+
+ // timeout structure reference
+ _timeout = 0;
+
+ // timed-out status
+ _timed_out = false;
+
+ }
+
+
+ void sockstreambuf::open( socket_domain_t domain, socket_type_t type, socket_protocol_t proto ) throw( sockexception ) {
+
+ // create a communication endpoint
+ _socket = ::socket( domain, type, proto );
+
+ // sanity check
+ if ( _socket == -1 ) {
+ throw sockexception();
+ }
+
+#ifdef SO_NOSIGPIPE
+ // suppress SIGPIPE (Mac OSX)
+ int optval = 1;
+ if ( setsockopt( _socket, SOL_SOCKET, SO_NOSIGPIPE, &optval, sizeof( optval ) ) != 0 ) {
+ throw sockexception();
+ }
+#endif
+
+ }
+
+
+ void sockstreambuf::close() throw() {
+
+ // sanity check
+ if ( _socket > -1 ) {
+
+ // sync
+ sync();
+
+ // close the socket
+ ::close( _socket );
+
+ // update socket data
+ _socket = -1;
+
+ }
+
+ }
+
+
+ void sockstreambuf::connect( const sockaddr * dest_addr, unsigned int timeout ) throw( sockexception, socktimeoutexception ) {
+
+ timeval t_val;
+ timeval * t_ptr;
+
+ // check timeout value
+ if ( timeout > 0 ) {
+
+ // setup timeval structure
+ t_val.tv_sec = timeout;
+ t_val.tv_usec = 0;
+
+ // update pointer
+ t_ptr = &t_val;
+
+ } else {
+
+ // fall-back to class value
+ t_ptr = _timeout;
+
+ }
+
+ // call overloaded connect()
+ connect( dest_addr, t_ptr );
+
+ }
+
+
+ void sockstreambuf::connect( const sockaddr * dest_addr, timeval * timeout ) throw( sockexception, socktimeoutexception ) {
+
+ // copy current flags
+ int s_flags = fcntl( _socket, F_GETFL );
+
+ // sanity check - affectively we ignore the fcntl() error
+ if ( s_flags == -1 ) {
+ s_flags = 0;
+ }
+
+ // setup timeout if needed
+ if ( timeout > 0 ) {
+
+ // make the socket non-blocking
+ if ( fcntl( _socket, F_SETFL, ( s_flags | O_NONBLOCK ) ) == -1 ) {
+ throw sockexception();
+ }
+
+ }
+
+ // connect
+ if ( ::connect( _socket, dest_addr->psockaddr(), dest_addr->size() ) != 0 ) {
+ throw sockexception();
+ }
+
+ // check for timeout if set
+ if ( timeout > 0 ) {
+
+ if (! ready( timeout ) ) {
+
+ // shutdown
+ ::shutdown( _socket, 2 );
+
+ // throw a timeout exception
+ if ( _timed_out ) {
+ throw socktimeoutexception( timeout, "sockstreambuf::connect()" );
+ }
+
+ }
+
+ // reset flags back to what they were
+ fcntl( _socket, F_SETFL, s_flags );
+
+ }
+
+ }
+
+
+ void sockstreambuf::bind( const sockaddr * bind_addr, bool reuse_addr ) throw( sockexception ) {
+
+ // set socket options - SO_REUSEADDR
+ if ( reuse_addr ) {
+
+ int optval = 1;
+ if ( setsockopt( _socket, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof( optval ) ) != 0 ) {
+ throw sockexception();
+ }
+
+ }
+
+ // bind
+ if ( ::bind( _socket, bind_addr->psockaddr(), bind_addr->size() ) != 0 ) {
+ throw sockexception();
+ }
+
+ }
+
+
+ void sockstreambuf::listen( int backlog ) throw( sockexception ) {
+
+ if ( ::listen( _socket, backlog ) != 0 ) {
+ throw sockexception();
+ }
+
+ }
+
+
+ sockstreambuf::socket_t sockstreambuf::accept() throw( sockexception ) {
+
+ socket_t peer_sock;
+
+ if ( ( peer_sock = ::accept( _socket, 0, 0 ) ) < 0 ) {
+ throw sockexception();
+ }
+
+ return peer_sock;
+
+ }
+
+
+ const sockstreambuf::socket_t & sockstreambuf::socket() const throw() {
+ return _socket;
+ }
+
+
+ const timeval * sockstreambuf::timeout( time_t sec, suseconds_t usec ) throw() {
+
+ _timeout = new timeval;
+
+ _timeout->tv_sec = sec;
+ _timeout->tv_usec = usec;
+
+ return _timeout;
+
+ }
+
+
+ void * sockstreambuf::clear_timeout() throw() {
+
+ // sanity check
+ if ( _timeout != 0 ) {
+
+ // delete structure
+ delete _timeout;
+
+ // set a null pointer
+ _timeout = 0;
+
+ }
+
+ return _timeout;
+
+ }
+
+
+ bool sockstreambuf::timedout() const throw() {
+ return _timed_out;
+ }
+
+
+ void sockstreambuf::init_buffers() throw() {
+
+ // allocate output buffer space
+ char * pbuf = new char[_bufsize];
+
+ // allocate input buffer space
+ char * gbuf = new char[_bufsize];
+
+ // setup output buffer
+ setp( pbuf, pbuf + ( _bufsize - 1 ) );
+
+ // setup input buffer
+ setg( gbuf, gbuf, gbuf );
+
+ }
+
+
+ void sockstreambuf::cleanup_buffers() throw() {
+
+ // cleanup output buffer
+ delete [] pbase();
+
+ // cleanup input buffer
+ delete [] eback();
+
+ }
+
+
+ int sockstreambuf::flush() throw( socktimeoutexception ) {
+
+ int flush_size = pptr() - pbase();
+ bool b_ready = false;
+
+ // sanity check
+ if ( flush_size > 0 ) {
+
+ try {
+ b_ready = ready( _timeout, false, true );
+ } catch ( sockexception &e ) {
+ // couldn't select the socket
+ return eof;
+ }
+
+ if ( b_ready ) {
+ if ( ::send( _socket, pbase(), flush_size, MSG_NOSIGNAL ) == flush_size ) {
+ pbump( -flush_size );
+ return flush_size;
+ }
+ } else {
+
+ // timed out - throw a timeout exception
+ if ( _timed_out ) {
+ throw socktimeoutexception( _timeout, "sockstreambuf::flush()" );
+ }
+
+ }
+
+ }
+
+ return eof;
+
+ }
+
+
+ int sockstreambuf::sync() throw() {
+
+ try {
+
+ // flush buffer
+ if ( flush() != eof ) {
+ return 0;
+ }
+
+ } catch ( socktimeoutexception &e ) {
+ // communication timeout - suppress the exception
+ }
+
+ // sync failed
+ return -1;
+
+ }
+
+
+ int sockstreambuf::overflow( int c ) throw( socktimeoutexception ) {
+
+ // sanity check
+ if ( c != eof ) {
+
+ // insert the overflowed char into the buffer
+ *pptr() = c;
+ pbump( 1 );
+
+ }
+
+ // flush the buffer - could throw a timeout exception
+ if ( flush() == eof ) {
+ return eof;
+ }
+
+ return c;
+
+ }
+
+
+ int sockstreambuf::underflow() throw( socktimeoutexception ) {
+
+ // sanity check - read position before end-of-buffer?
+ if ( gptr() < egptr() ) {
+ return traits_type::to_int_type( *gptr() );
+ }
+
+
+ char * read_buffer;
+ size_t putback_size = gptr() - eback();
+ size_t readable_size = 0;
+
+ bool b_ready = false;
+ ssize_t read_size = 0;
+
+ // sanitise putback size
+ if ( putback_size > _putbacksize ) {
+ putback_size = _putbacksize;
+ }
+
+ // update read buffer position
+ read_buffer = eback() + putback_size;
+
+ // calculate read buffer size
+ readable_size = _bufsize - putback_size;
+
+ // check for availability
+ try {
+ b_ready = ready( _timeout, true, false );
+ } catch ( sockexception &e ) {
+ // couldn't select the socket
+ return eof;
+ }
+
+ // read from socket
+ if ( b_ready ) {
+ read_size = ::read( _socket, read_buffer, readable_size );
+ } else {
+
+ // timed out - throw a timeout exception
+ if ( _timed_out ) {
+ throw socktimeoutexception( _timeout, "sockstreambuf::overflow()" );
+ }
+
+ }
+
+ // sanity check
+ if ( read_size <= 0 ) {
+ return eof;
+ }
+
+ // update pointers
+ setg( eback(), read_buffer, read_buffer + read_size );
+
+ // return next character
+ return traits_type::to_int_type( *gptr() );
+
+ }
+
+
+ bool sockstreambuf::ready( timeval * timeout, bool chk_read, bool chk_write ) throw( sockexception ) {
+
+ // sanity check
+ if ( _socket < 0 ) {
+ throw sockexception( "sockstreambuf::ready(): invalid socket" );
+ }
+
+
+ fd_set fds;
+ fd_set * read_fds = 0;
+ fd_set * write_fds = 0;
+
+ // timespec structure
+ timespec * t_spec = 0;
+
+
+ // set the fd_set so we only check our socket
+ memset( &fds, 0, sizeof( fds ) );
+ FD_SET( _socket, &fds );
+
+ // set the actions we want to check
+ if ( chk_read ) {
+ read_fds = &fds;
+ }
+
+ if ( chk_write ) {
+ write_fds = &fds;
+ }
+
+ // reset timed-out status
+ _timed_out = false;
+
+ // create timespec structure from timeval structure
+ if ( timeout != 0 ) {
+ t_spec = new timespec;
+ t_spec->tv_sec = timeout->tv_sec;
+ t_spec->tv_nsec = ( timeout->tv_usec * 1000 );
+ }
+
+ // select the socket
+ int s_status = ::pselect( ( _socket + 1 ), read_fds, write_fds, 0, t_spec, 0 );
+
+ // cleanup
+ if ( t_spec != 0 ) {
+ delete t_spec;
+ }
+
+ // check status
+ switch ( s_status ) {
+ case 0:
+ // timed-out
+ _timed_out = true;
+ break;
+
+ case -1:
+ throw sockexception();
+ break;
+
+ default:
+ break;
+ }
+
+ // sanity check
+ if ( FD_ISSET( _socket, &fds ) ) {
+ return true;
+ }
+
+ return false;
+
+ }
+
+} /* end of namespace psocksxx */
+
diff --git a/lib/psocksxx/sockstreambuf.h b/lib/psocksxx/sockstreambuf.h
new file mode 100644
index 0000000..ac1ae2f
--- /dev/null
+++ b/lib/psocksxx/sockstreambuf.h
@@ -0,0 +1,345 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#ifndef PSOCKSXX_SOCKSTREAMBUF_H
+#define PSOCKSXX_SOCKSTREAMBUF_H
+
+#include <psocksxx/socktimeoutexception.h>
+#include <psocksxx/sockaddr.h>
+
+#include <streambuf>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <unistd.h>
+
+#ifndef SOCKSTREAMBUF_SIZE
+#define SOCKSTREAMBUF_SIZE 1024
+#endif
+
+#ifndef SOCKSTREAMBUF_PUTBACK_SIZE
+#define SOCKSTREAMBUF_PUTBACK_SIZE 8
+#endif
+
+
+namespace psocksxx {
+
+ /**
+ * @brief Socket stream buffer class
+ *
+ * This buffer class associates its both input and output
+ * sequences with an external POSIX socket.
+ */
+ class sockstreambuf : public std::streambuf {
+ public:
+
+ /** socket data type definition */
+ typedef int socket_t;
+
+ /** socket end-of-file type */
+ enum eof_t {
+ eof = -1 /*!< end of file */
+ };
+
+ /** socket domains type definition */
+ enum socket_domain_t {
+ pf_local = PF_LOCAL, /*!< Host-internal protocols */
+ pf_inet = PF_INET, /*!< Internet version 4 protocols */
+ pf_route = PF_ROUTE, /*!< Internal Routing protocol */
+ pf_key = PF_KEY, /*!< Internal key-management function */
+ pf_inet6 = PF_INET6 /*!< Internet version 6 protocols */
+ };
+
+ /** socket types type definition */
+ enum socket_type_t {
+ sock_stream = SOCK_STREAM,
+ sock_dgram = SOCK_DGRAM,
+ sock_raw = SOCK_RAW,
+ sock_rdm = SOCK_RDM,
+ sock_seqpacket = SOCK_SEQPACKET
+ };
+
+ /** socket protocols type definition */
+ enum socket_protocol_t {
+ proto_unspec = 0, /*!< Unspecified system default */
+ ipproto_ip = IPPROTO_IP, /*!< Internet protocol */
+ ipproto_ipv6 = IPPROTO_IPV6, /*!< Internet Protocol Version 6 */
+ ipproto_icmp = IPPROTO_ICMP, /*!< Control message protocol */
+ ipproto_raw = IPPROTO_RAW, /*!< Raw IP Packets Protocol */
+ ipproto_tcp = IPPROTO_TCP, /*!< Transmission control protocol */
+ ipproto_udp = IPPROTO_UDP /*!< User datagram protocol */
+ };
+
+
+ sockstreambuf() throw(); //!< constructor
+ virtual ~sockstreambuf(); //!< destructor
+
+ /**
+ * @brief overloaded constructor
+ * @param socket socket data
+ *
+ * Create an instance with the passed in sockstreambuf::socket_t
+ * type socket. It is assumed that the socket is initialised and
+ * ready to use.
+ *
+ */
+ sockstreambuf( socket_t socket ) throw();
+
+ /**
+ * @brief get internal socket data
+ * @return socket data
+ *
+ * Returns a read-only reference to the internal POSIX socket
+ * data.
+ *
+ */
+ const socket_t & socket() const throw();
+
+ /**
+ * @brief open a socket
+ * @param domain communications domain for the socket
+ * @param type socket communications type
+ * @param proto socket communications protocol
+ * @throw psocksxx::sockexception socket exception
+ *
+ * Open a socket and initialise socket communications.
+ *
+ */
+ void open( socket_domain_t domain, socket_type_t type, socket_protocol_t proto = proto_unspec ) throw( sockexception );
+
+ /**
+ * @brief close open sockets
+ *
+ * Close any open socket connections used by this buffer. This
+ * will also flush any data in the buffer before closing.
+ *
+ */
+ void close() throw();
+
+ /**
+ * @brief flush the socket output buffer
+ * @return number of characters flushed
+ * @throw psocksxx::socktimeoutexception on socket timeout
+ *
+ * Flush the socket buffer by writing date into the
+ * socket and returns the number of characters flushed.
+ * If the output buffer is empty sockstreambuf::eof is returned.
+ *
+ */
+ virtual int flush() throw( socktimeoutexception );
+
+
+ /**
+ * @brief initiate a connection on a socket
+ * @param dest_addr destination address to connect to
+ * @param timeout connection timeout value in seconds
+ * @throw psocksxx::sockexception socket exception
+ * @throw psocksxx::socktimeoutexception connection timeout
+ * exception
+ *
+ * Initiate a connection on a socket previously opened using
+ * open() method. If the timeout value is 0 (default) then
+ * the timeouts are ignored.
+ *
+ */
+ void connect( const sockaddr * dest_addr, unsigned int timeout = 0 ) throw( sockexception, socktimeoutexception );
+
+ /**
+ * @brief initiate a connection on a socket
+ * @param dest_addr destination address to connect to
+ * @param timeout connection timeout value as a reference to a
+ * @c timeval structure
+ *
+ * @throw psocksxx::sockexception socket exception
+ * @throw psocksxx::socktimeoutexception connection timeout
+ * exception
+ *
+ * Initiate a connection on a socket previously opened using
+ * open() method.
+ *
+ */
+ void connect( const sockaddr * dest_addr, timeval * timeout ) throw( sockexception, socktimeoutexception );
+
+ /**
+ * @brief bind the socket to a specified address
+ * @param bind_addr address to bind to
+ * @param reuse_addr allow address to be re-used
+ * @throw psocksxx::sockexception socket exception
+ *
+ * After a socket is configured using open() this method can
+ * be used to assign an address to it. If @c reuse_addr is set
+ * to @c true then this will try to re-use the address unless
+ * the address is actively listening.
+ *
+ */
+ void bind( const sockaddr * bind_addr, bool reuse_addr = false ) throw( sockexception );
+
+ /**
+ * @brief make the socket passive and capable of accepting connections
+ * @param backlog maximum length of the queue for pending connections
+ * and defaults to SOMAXCONN (128) defined in @c <sys/socket.h>
+ *
+ * @throw psocksxx::sockexception socket exception
+ *
+ * This method will make the currently opened socket connection
+ * to passive and capable of accepting client connections using accept()
+ * method.
+ *
+ */
+ void listen( int backlog = SOMAXCONN ) throw( sockexception );
+
+ /**
+ * @brief accept a connection on a listening (passive) socket
+ * @throw psocksxx::sockexception socket exception
+ * @return peer socket data structure
+ *
+ * This method will accept incoming connections on a socket
+ * set to be passive using the listen() method. Upon success
+ * this will return the peer socket data structure that can be used
+ * to create a socket stream buffer instance to communicate
+ * with the accepted socket connection.
+ *
+ */
+ socket_t accept() throw( sockexception );
+
+ /**
+ * @brief set the timeout value for the socket
+ * @param sec seconds
+ * @param usec microseconds
+ * @return a reference to the internal timeout structure
+ *
+ * This method will set the timeout for the socket and make this
+ * a non-blocking socket. Note that you cannot clear the timeout
+ * by passing in a 0 timeout, use clear_timeout() method instead.
+ *
+ */
+ const timeval * timeout( time_t sec, suseconds_t usec ) throw();
+
+ /**
+ * @brief clear the timeout value for the socket
+ * @return a reference to the internal timeout structure which will
+ * always be a null-pointer (@c 0) after clearing the timeout
+ *
+ * This will clear any timeout values set for the socket affectively
+ * making this a blocking socket by default.
+ *
+ */
+ void * clear_timeout() throw();
+
+ /**
+ * @brief get the timed-out status
+ * @return boolean @c true if timed-out flag is set or @c false
+ * otherwise.
+ *
+ * Returns the timed-out status.
+ *
+ */
+ bool timedout() const throw();
+
+
+ protected:
+
+ /**
+ * @brief initialise internal buffers
+ */
+ void init_buffers() throw();
+
+ /**
+ * @brief cleanup internal buffers
+ */
+ void cleanup_buffers() throw();
+
+ /**
+ * @brief sync data with the socket
+ * @return 0 or -1 to denote success or failure
+ *
+ * Synchronise the buffer with the associated socket
+ * by flushing data from the buffer to the socket.
+ *
+ */
+ virtual int sync() throw();
+
+ /**
+ * @brief consumes the buffer by writing the contents to
+ * the socket
+ *
+ * @param c additional character to consume
+ * @return sockstreambuf::eof to indicate failure or @a c
+ * if successful.
+ *
+ * @throw psocksxx::socktimeoutexception on socket timeout
+ *
+ *
+ * Consumes the buffer contents and writes to the opened socket.
+ * If @a c is not sockstreambuf::eof then @a c is also written
+ * out.
+ *
+ */
+ virtual int overflow( int c = eof ) throw( socktimeoutexception );
+
+ /**
+ * @brief read more data into the buffer from the socket
+ * @return the first character from the buffer or sockstreambuf::eof
+ * if no data is available to read
+ *
+ * @throw psocksxx::socktimeoutexception on socket timeout
+ *
+ *
+ * This reads more data into the buffer from the socket when
+ * the input buffer is empty and returns the next readable
+ * character from the buffer. If the buffer is empty and no
+ * data is available through the socket, this returns sockstreambuf::eof.
+ *
+ */
+ virtual int underflow() throw( socktimeoutexception );
+
+ /**
+ * @brief check for the read/write availability on the socket
+ * @param timeout timeout value reference to a @c timeval structure
+ * @param chk_read check for read availability
+ * @param chk_write check for write availability
+ * @throw psocksxx::sockexception socket exception
+ * @return boolean @c true to denote availability or @c false
+ * if none of the checked actions are available.
+ *
+ * This will check the socket for read and/or write availability.
+ *
+ */
+ bool ready( timeval * timeout, bool chk_read = true, bool chk_write = true ) throw( sockexception );
+
+
+ private:
+
+ /** POSIX socket data */
+ socket_t _socket;
+
+ size_t _bufsize;
+ size_t _putbacksize;
+
+ timeval * _timeout;
+ bool _timed_out;
+
+
+ void init_defaults() throw();
+
+ };
+
+} /* end of namespace psocksxx */
+
+#endif /* !PSOCKSXX_SOCKSTREAMBUF_H */
+
diff --git a/lib/psocksxx/socktimeoutexception.cpp b/lib/psocksxx/socktimeoutexception.cpp
new file mode 100644
index 0000000..d391630
--- /dev/null
+++ b/lib/psocksxx/socktimeoutexception.cpp
@@ -0,0 +1,50 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include "socktimeoutexception.h"
+
+#include <sstream>
+
+
+namespace psocksxx {
+
+ socktimeoutexception::socktimeoutexception( const char * message ) throw() {
+ _message = message;
+ }
+
+ socktimeoutexception::socktimeoutexception( const timeval * t_val, const char * method ) throw() {
+
+ // string stream
+ std::stringstream ss;
+
+ if ( method != 0 ) {
+ ss << method << " ";
+ }
+
+ ss << "timed out (" << t_val->tv_sec << "." << t_val->tv_usec << "s)";
+
+ // update exception message
+ _message = ss.str();
+
+ }
+
+ socktimeoutexception::~socktimeoutexception() throw() { }
+
+} /* end of namespace psocksxx */
+
diff --git a/lib/psocksxx/socktimeoutexception.h b/lib/psocksxx/socktimeoutexception.h
new file mode 100644
index 0000000..427dc3e
--- /dev/null
+++ b/lib/psocksxx/socktimeoutexception.h
@@ -0,0 +1,67 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#ifndef PSOCKSXX_SOCKTIMEOUTEXCEPTION_H
+#define PSOCKSXX_SOCKTIMEOUTEXCEPTION_H
+
+#include <psocksxx/sockexception.h>
+
+#include <sys/time.h>
+
+
+namespace psocksxx {
+
+ /**
+ * @brief Socket timeout exception
+ *
+ * This acts as the socket timeout exception class.
+ *
+ */
+ class socktimeoutexception : public sockexception {
+ public:
+
+ /**
+ * @brief constructor
+ * @param message exception message
+ *
+ * Create an timeout exception instance with the passed in exception
+ * message.
+ *
+ */
+ socktimeoutexception( const char * message ) throw();
+
+ /**
+ * @brief constructor
+ * @param t_val timed-out value
+ * @param method action/method that timed-out
+ *
+ * This will take the passed in timed-out value and the action
+ * to construct the exception message.
+ *
+ */
+ socktimeoutexception( const timeval * t_val, const char * method = 0 ) throw();
+
+ virtual ~socktimeoutexception() throw(); //!< destructor
+
+ };
+
+} /* end of namespace psocksxx */
+
+#endif /* !PSOCKSXX_SOCKTIMEOUTEXCEPTION_H */
+
diff --git a/lib/psocksxx/tcpnsockstream.cpp b/lib/psocksxx/tcpnsockstream.cpp
new file mode 100644
index 0000000..461a649
--- /dev/null
+++ b/lib/psocksxx/tcpnsockstream.cpp
@@ -0,0 +1,36 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include "tcpnsockstream.h"
+
+
+namespace psocksxx {
+
+ tcpnsockstream::tcpnsockstream() throw( sockexception ) :
+ nsockstream( sockstreambuf::sock_stream, sockstreambuf::ipproto_tcp ) {
+
+ }
+
+
+ tcpnsockstream::~tcpnsockstream() throw() {
+
+ }
+
+} /* end of namespace psocksxx */
+
diff --git a/lib/psocksxx/tcpnsockstream.h b/lib/psocksxx/tcpnsockstream.h
new file mode 100644
index 0000000..434b93e
--- /dev/null
+++ b/lib/psocksxx/tcpnsockstream.h
@@ -0,0 +1,56 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#ifndef PSOCKSXX_TCPNSOCKSTREAM_H
+#define PSOCKSXX_TCPNSOCKSTREAM_H
+
+#include <psocksxx/nsockstream.h>
+
+
+namespace psocksxx {
+
+ /**
+ * @brief TCP/IP controller class
+ *
+ * This acts as the controller for TCP/TP communication streams.
+ *
+ */
+ class tcpnsockstream : public nsockstream {
+ public:
+
+ /**
+ * @brief constructor
+ * @throw psocksxx::sockexception socket exception
+ *
+ * Initialise a TCP/IP communication stream.
+ *
+ */
+ tcpnsockstream() throw( sockexception );
+
+ /**
+ * @brief destructor
+ */
+ virtual ~tcpnsockstream() throw();
+
+ };
+
+} /* end of namespace psocksxx */
+
+#endif /* !PSOCKSXX_TCPNSOCKSTREAM_H */
+
diff --git a/lib/psocksxx/udpnsockstream.cpp b/lib/psocksxx/udpnsockstream.cpp
new file mode 100644
index 0000000..f12ad60
--- /dev/null
+++ b/lib/psocksxx/udpnsockstream.cpp
@@ -0,0 +1,36 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include "udpnsockstream.h"
+
+
+namespace psocksxx {
+
+ udpnsockstream::udpnsockstream() throw( sockexception ) :
+ nsockstream( sockstreambuf::sock_dgram, sockstreambuf::ipproto_udp ) {
+
+ }
+
+
+ udpnsockstream::~udpnsockstream() throw() {
+
+ }
+
+} /* end of namespace psocksxx */
+
diff --git a/lib/psocksxx/udpnsockstream.h b/lib/psocksxx/udpnsockstream.h
new file mode 100644
index 0000000..8c33a24
--- /dev/null
+++ b/lib/psocksxx/udpnsockstream.h
@@ -0,0 +1,57 @@
+/*
+* psocksxx - A C++ wrapper for POSIX sockets
+* Copyright (C) 2013 Uditha Atukorala
+*
+* This software library is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This software library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this software library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#ifndef PSOCKSXX_UDPNSOCKSTREAM_H
+#define PSOCKSXX_UDPNSOCKSTREAM_H
+
+#include <psocksxx/nsockstream.h>
+
+
+namespace psocksxx {
+
+ /**
+ * @brief UDP over IPv4 controller class
+ *
+ * This acts as the controller class for UDP over IPv4 communication
+ * streams.
+ *
+ */
+ class udpnsockstream : public nsockstream {
+ public:
+
+ /**
+ * @brief constructor
+ * @throw psocksxx::sockexception socket exception
+ *
+ * Initialise a UDP communication stream over IPv4.
+ *
+ */
+ udpnsockstream() throw( sockexception );
+
+ /**
+ * @brief destructor
+ */
+ virtual ~udpnsockstream() throw();
+
+ };
+
+} /* end of namespace psocksxx */
+
+#endif /* !PSOCKSXX_UDPNSOCKSTREAM_H */
+