Netxx-0.3.2/ 0000755 0001750 0001750 00000000000 12173720372 012100 5 ustar daniel daniel Netxx-0.3.2/docs/ 0000755 0001750 0001750 00000000000 12173720372 013030 5 ustar daniel daniel Netxx-0.3.2/docs/project/ 0000755 0001750 0001750 00000000000 12173720372 014476 5 ustar daniel daniel Netxx-0.3.2/docs/project/resources.xml 0000644 0001750 0001750 00000013457 12173720353 017243 0 ustar daniel daniel
-
Very quiet, mostly release announcements. [archive]
-
Questions, comments, stories? This is the place. [archive]
-
Online HTML version of the Developers Manual
-
Online HTML version of the Developers Manual (everything in one file)
-
PDF version of the Developers Manual
-
Doxygen generated API documentation
-
Tarball with doxygen generated API documentation
-
Shows how simple the Netxx::Address and Netxx::Stream classes are to use
-
A very simple example of the Netxx::Stream class
-
Example TCP (Stream) server
-
Shows how to use the Netxx::Datagram class to send datagrams
-
Example UDP (Datagram) server
-
Shows the use of the Netxx::TLS::Stream and Netxx::TLS::Certificate classes
-
TCP echo client using IOStreams
-
TLS client example
-
TLS server example
-
Another Netxx::Stream example code
-
Another Netxx::Datagram example
-
Multi-protocol server that listens on TCP and UDP ports
-
Shows off almost all of the Netxx classes
-
A very large and complex, do everything library
-
Another do everything library that glosses over network programming
-
Framework to manage TCP, TCPSSL and UDP connections
-
Huge networking library that implements strange things like string processing
-
A small class library for C++ that supports an easy usage of socket-programming
-
A thin wrapper for socket and thread support (pre-standard C++ coding style)
-
A simple alternative to the STL that includes multi-threading and networking
-
An iostream based C++ socket library
-
A C++ class library that provides you with an iostream based interface to sockets
Netxx-0.3.2/docs/project/download.xml 0000644 0001750 0001750 00000007455 12173720353 017041 0 ustar daniel daniel
- Perl (at least version 5.5) to run configure.pl
- OpenSSL >= 0.9.6e if you want TLS support
- A C++ compiler
The Netxx::Netbuf is not supported with this compiler, you must use the --disable-streambuf option to the
configure.pl script to turn it off.
The Netxx::Netbuf is not supported with this compiler, you must use the --disable-streambuf option to the
configure.pl script to turn it off.
The Netxx::Netbuf is not supported with this compiler, you must use the --disable-streambuf option to the
configure.pl script to turn it off.
Name resolution causes errors. Anyone want to help?
Name resolution causes errors. Anyone want to help?
The Netxx::Netbuf is not supported with this compiler, you must use the --disable-streambuf option to the
configure.pl script to turn it off. Better yet, use the build/macosx/configure.sh script to configure
Netxx.
This is a beta version of what became GCC 3.1. It contains bugs, including problems with exceptions. When
you throw an exception the code will continue right after the throw statment.
The Netxx::Netbuf is not supported with this compiler, you must use the --disable-streambuf option to the
configure.pl script to turn it off. Better yet, use the build/macosx/configure.sh script to configure
Netxx.
Netxx-0.3.2/docs/project/news.xml 0000644 0001750 0001750 00000006051 12173720353 016175 0 ustar daniel daniel
Thanks to the work of volunteers, Netxx version 0.3.2 has been
released. This version fixed a few major and minor bugs.
Netxx now has a project page on SourceForge.net.
Please take some time to review the site and volunteer to fix some bugs.
Version 0.3.1 is a bug fix release. A few exception safety
issues have been fixed, plus some changes for the MacOSX and
Win32 ports.
With a little over a year of work, Netxx 0.3.0 has been
released! This version has a lot of changes, some external, but
a lot of internal work. Plus TLS support is almost complete!
The API is much better now, and the code is very solid. We
wanted to make this release so that everyone could become
familiar with the new API.
As part of my portfolio I have created a new logo for Netxx.
Also note that version 0.3.0 is in the works and it's going to
be very cool!
Netxx version 0.2 is out. This is still an alpha release of
course. I wanted to get all the new changes out although some of
them are not ready, like TLS on windows. Expect changes in a few
classes, I am going to make the library a little easier to use.
A bug was found in the code that calls select. It did not pass
select a NULL pointer for a 0 timeout. This is fixed in CVS. The
fix will also be in the upcoming 0.2 version.
The Netxx port to Windows is almost complete. As soon as the
build system is more complete, Netxx 0.2 will be released.
Netxx now supports TLS via OpenSSL and some wrapper classes.
Official Netxx TLS Release coming soon.
An early alpha version of Netxx was released. This is so that
developers can start to review the API and provide feedback.
This is still an alpha release that the API is subject to
change. With that said, it is very stable.
Netxx-0.3.2/docs/project/project.xml 0000644 0001750 0001750 00000004124 12173720353 016666 0 ustar daniel daniel
Netxx is a C++ network programming library. It is designed to
take the pain out of programming network communications
applications.
It does this by providing an easy to use and cross-platform
interface. As a side effect, you get the safety of automatic
resource management and smaller, simpler code.
Very clean API with total abstraction from any operating system calls.
No networking or operating system headers are used in the Netxx header files.
Appropriate use of C++ technologies such as namespaces, templates, inheritance and exceptions. All Netxx
classes are in the Netxx namespace and exceptions are used only in exceptional situations.
Includes support for TLS/SSL (via OpenSSL), IPv6 and Local/Unix Domain Sockets (on operating systems that support
them).
Cross-platform support. Netxx currently supports most flavors of Unix, Windows and MacOS X.
An IOStreams streambuf is provided so you can treat network connections just like a std::iostream.
Berkeley style license so you can do whatever you want with Netxx, including commercial use.
Netxx-0.3.2/docs/project/Makefile 0000644 0001750 0001750 00000000112 12173720353 016127 0 ustar daniel daniel PROJECT_NAME=netxx
.include "${HOME}/develop/project-xslt/etc/project.mk"
Netxx-0.3.2/docs/CREDITS 0000644 0001750 0001750 00000001765 12173720353 014060 0 ustar daniel daniel Credits
Netxx it brought to you by the following people.
* Peter Jones
+ Original designer of Netxx and project maintainer.
+ Ported to the Win32 platform.
+ Ported to the MacOS X platform.
+ Added TLS support via OpenSSL.
* Alex Mitrofanov
+ Updated all the TLS code to the new internal API.
+ Completed Netxx::TLS::Stream so that it could act as a server.
+ Fixed a bug in the Netxx::TLS::Stream::read() function.
+ Wrote the tls_* examples.
+ Wrote the http_https_server example
+ Fixed up the new Netxx::Peer code to be more portable.
+ Wrote the Netxx::TLS::Certificate class.
* Steve Bannister
+ Found and fixed a bug in the Netxx::Socket class.
+ Found a bug in the Netxx::StreamBase class relating to non-blocking
connects.
* Isaac Foraker
+ Answered stupid Win32 questions.
Netxx-0.3.2/docs/doxygen/ 0000755 0001750 0001750 00000000000 12173720372 014505 5 ustar daniel daniel Netxx-0.3.2/docs/doxygen/doxyfile 0000644 0001750 0001750 00000077565 12173720353 016276 0 ustar daniel daniel # Doxyfile 1.2.10
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project
#
# All text after a hash (#) is considered a comment and will be ignored
# The format is:
# TAG = value [value, ...]
# For lists items can also be appended using:
# TAG += value [value, ...]
# Values that contain spaces should be placed between quotes (" ")
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.
PROJECT_NAME = Netxx
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = HEAD
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
OUTPUT_DIRECTORY =
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
# documentation generated by doxygen is written. Doxygen will use this
# information to generate all constant output in the proper language.
# The default language is English, other supported languages are:
# Brazilian, Chinese, Croatian, Czech, Danish, Dutch, Finnish, French,
# German, Hungarian, Italian, Japanese, Korean, Norwegian, Polish,
# Portuguese, Romanian, Russian, Slovak, Slovene, Spanish and Swedish.
OUTPUT_LANGUAGE = English
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
# documentation are documented, even if no documentation was available.
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
EXTRACT_ALL = NO
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
EXTRACT_PRIVATE = NO
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
EXTRACT_STATIC = NO
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
# undocumented members of documented classes, files or namespaces.
# If set to NO (the default) these members will be included in the
# various overviews, but no documentation section is generated.
# This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_MEMBERS = YES
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy.
# If set to NO (the default) these class will be included in the various
# overviews. This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_CLASSES = YES
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
# include brief member descriptions after the members that are listed in
# the file and class documentation (similar to JavaDoc).
# Set to NO to disable this.
BRIEF_MEMBER_DESC = YES
# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
# the brief description of a member or function before the detailed description.
# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
# brief descriptions will be completely suppressed.
REPEAT_BRIEF = YES
# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
# Doxygen will generate a detailed section even if there is only a brief
# description.
ALWAYS_DETAILED_SEC = YES
# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
# path before files name in the file list and in the header files. If set
# to NO the shortest path that makes the file name unique will be used.
FULL_PATH_NAMES = NO
# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
# can be used to strip a user defined part of the path. Stripping is
# only done if one of the specified strings matches the left-hand part of
# the path. It is allowed to use relative paths in the argument list.
STRIP_FROM_PATH =
# The INTERNAL_DOCS tag determines if documentation
# that is typed after a \internal command is included. If the tag is set
# to NO (the default) then the documentation will be excluded.
# Set it to YES to include the internal documentation.
INTERNAL_DOCS = NO
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
# generate a class diagram (in Html and LaTeX) for classes with base or
# super classes. Setting the tag to NO turns the diagrams off.
CLASS_DIAGRAMS = YES
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
# be generated. Documented entities will be cross-referenced with these sources.
SOURCE_BROWSER = YES
# Setting the INLINE_SOURCES tag to YES will include the body
# of functions and classes directly in the documentation.
INLINE_SOURCES = NO
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
# doxygen to hide any special comment blocks from generated source code
# fragments. Normal C and C++ comments will always remain visible.
STRIP_CODE_COMMENTS = NO
# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
# file names in lower case letters. If set to YES upper case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
# users are adviced to set this option to NO.
CASE_SENSE_NAMES = YES
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
# (but less readable) file names. This can be useful is your file systems
# doesn't support long names like on DOS, Mac, or CD-ROM.
SHORT_NAMES = NO
# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
# will show members with their full class and namespace scopes in the
# documentation. If set to YES the scope will be hidden.
HIDE_SCOPE_NAMES = NO
# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
# will generate a verbatim copy of the header file for each class for
# which an include is specified. Set to NO to disable this.
VERBATIM_HEADERS = YES
# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
# will put list of the files that are included by a file in the documentation
# of that file.
SHOW_INCLUDE_FILES = YES
# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
# will interpret the first line (until the first dot) of a JavaDoc-style
# comment as the brief description. If set to NO, the JavaDoc
# comments will behave just like the Qt-style comments (thus requiring an
# explict @brief command for a brief description.
JAVADOC_AUTOBRIEF = YES
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
# member inherits the documentation from any documented member that it
# reimplements.
INHERIT_DOCS = YES
# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
# is inserted in the documentation for inline members.
INLINE_INFO = YES
# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
# will sort the (detailed) documentation of file and class members
# alphabetically by member name. If set to NO the members will appear in
# declaration order.
SORT_MEMBER_DOCS = YES
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
# tag is set to YES, then doxygen will reuse the documentation of the first
# member in the group (if any) for the other members of the group. By default
# all members of a group must be documented explicitly.
DISTRIBUTE_GROUP_DOC = NO
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
# Doxygen uses this value to replace tabs by spaces in code fragments.
TAB_SIZE = 8
# The GENERATE_TODOLIST tag can be used to enable (YES) or
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
GENERATE_TODOLIST = NO
# The GENERATE_TESTLIST tag can be used to enable (YES) or
# disable (NO) the test list. This list is created by putting \test
# commands in the documentation.
GENERATE_TESTLIST = NO
# The GENERATE_BUGLIST tag can be used to enable (YES) or
# disable (NO) the bug list. This list is created by putting \bug
# commands in the documentation.
GENERATE_BUGLIST = NO
# This tag can be used to specify a number of aliases that acts
# as commands in the documentation. An alias has the form "name=value".
# For example adding "sideeffect=\par Side Effects:\n" will allow you to
# put the command \sideeffect (or @sideeffect) in the documentation, which
# will result in a user defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines.
ALIASES =
# The ENABLED_SECTIONS tag can be used to enable conditional
# documentation sections, marked by \if sectionname ... \endif.
ENABLED_SECTIONS =
# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
# the initial value of a variable or define consist of for it to appear in
# the documentation. If the initializer consists of more lines than specified
# here it will be hidden. Use a value of 0 to hide initializers completely.
# The appearance of the initializer of individual variables and defines in the
# documentation can be controlled using \showinitializer or \hideinitializer
# command in the documentation regardless of this setting.
MAX_INITIALIZER_LINES = 30
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C.
# For instance some of the names that are used will be different. The list
# of all members will be omitted, etc.
OPTIMIZE_OUTPUT_FOR_C = NO
# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
# at the bottom of the documentation of classes and structs. If set to YES the
# list will mention the files that were used to generate the documentation.
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
# The QUIET tag can be used to turn on/off the messages that are generated
# by doxygen. Possible values are YES and NO. If left blank NO is used.
QUIET = YES
# The WARNINGS tag can be used to turn on/off the warning messages that are
# generated by doxygen. Possible values are YES and NO. If left blank
# NO is used.
WARNINGS = YES
# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
# automatically be disabled.
WARN_IF_UNDOCUMENTED = YES
# The WARN_FORMAT tag determines the format of the warning messages that
# doxygen can produce. The string should contain the $file, $line, and $text
# tags, which will be replaced by the file and line number from which the
# warning originated and the warning text.
WARN_FORMAT =
# The WARN_LOGFILE tag can be used to specify a file to which warning
# and error messages should be written. If left blank the output is written
# to stderr.
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
# The INPUT tag can be used to specify the files and/or directories that contain
# documented source files. You may enter file names like "myfile.cpp" or
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = ../../include/
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
FILE_PATTERNS = *.h
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
# If left blank NO is used.
RECURSIVE = YES
# The EXCLUDE tag can be used to specify files and/or directories that should
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE =
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
# certain files from those directories.
EXCLUDE_PATTERNS =
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
# the \include command).
EXAMPLE_PATH =
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
EXAMPLE_PATTERNS =
# The IMAGE_PATH tag can be used to specify one or more files or
# directories that contain image that are included in the documentation (see
# the \image command).
IMAGE_PATH =
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
# by executing (via popen()) the command , where
# is the value of the INPUT_FILTER tag, and is the name of an
# input file. Doxygen will then use the output that the filter program writes
# to standard output.
INPUT_FILTER =
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
# INPUT_FILTER) will be used to filter the input files when producing source
# files to browse.
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
# of all compounds will be generated. Enable this if the project
# contains a lot of classes, structs, unions or interfaces.
ALPHABETICAL_INDEX = YES
# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
# in which this list will be split (can be a number in the range [1..20])
COLS_IN_ALPHA_INDEX = 4
# In case all classes in a project start with a common prefix, all
# classes will be put under the same header in the alphabetical index.
# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
# should be ignored while generating the index headers.
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
# generate HTML output.
GENERATE_HTML = YES
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `html' will be used as the default path.
HTML_OUTPUT =
# The HTML_HEADER tag can be used to specify a personal HTML header for
# each generated HTML page. If it is left blank doxygen will generate a
# standard header.
HTML_HEADER =
# The HTML_FOOTER tag can be used to specify a personal HTML footer for
# each generated HTML page. If it is left blank doxygen will generate a
# standard footer.
HTML_FOOTER =
# The HTML_STYLESHEET tag can be used to specify a user defined cascading
# style sheet that is used by each HTML page. It can be used to
# fine-tune the look of the HTML output. If the tag is left blank doxygen
# will generate a default style sheet
HTML_STYLESHEET =
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
# files or namespaces will be aligned in HTML using tables. If set to
# NO a bullet list will be used.
HTML_ALIGN_MEMBERS = YES
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
# will be generated that can be used as input for tools like the
# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
# of the generated HTML documentation.
GENERATE_HTMLHELP = NO
# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
# controls if a separate .chi index file is generated (YES) or that
# it should be included in the master .chm file (NO).
GENERATE_CHI = NO
# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
# controls whether a binary table of contents is generated (YES) or a
# normal table of contents (NO) in the .chm file.
BINARY_TOC = NO
# The TOC_EXPAND flag can be set to YES to add extra items for group members
# to the contents of the Html help documentation and to the tree view.
TOC_EXPAND = NO
# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
# top of each HTML page. The value NO (the default) enables the index and
# the value YES disables it.
DISABLE_INDEX = NO
# This tag can be used to set the number of enum values (range [1..20])
# that doxygen will group on one line in the generated HTML documentation.
ENUM_VALUES_PER_LINE = 4
# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
# generated containing a tree-like index structure (just like the one that
# is generated for HTML Help). For this to work a browser that supports
# JavaScript and frames is required (for instance Netscape 4.0+
# or Internet explorer 4.0+).
GENERATE_TREEVIEW = NO
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
# used to set the initial width (in pixels) of the frame in which the tree
# is shown.
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
# generate Latex output.
GENERATE_LATEX = NO
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `latex' will be used as the default path.
LATEX_OUTPUT =
# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
# LaTeX documents. This may be useful for small projects and may help to
# save some trees in general.
COMPACT_LATEX = NO
# The PAPER_TYPE tag can be used to set the paper type that is used
# by the printer. Possible values are: a4, a4wide, letter, legal and
# executive. If left blank a4wide will be used.
PAPER_TYPE = a4wide
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
# packages that should be included in the LaTeX output.
EXTRA_PACKAGES =
# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
# the generated latex document. The header should contain everything until
# the first chapter. If it is left blank doxygen will generate a
# standard header. Notice: only use this tag if you know what you are doing!
LATEX_HEADER =
# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
# is prepared for conversion to pdf (using ps2pdf). The pdf file will
# contain links (just like the HTML output) instead of page references
# This makes the output suitable for online browsing using a pdf viewer.
PDF_HYPERLINKS = NO
# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
# plain latex in the generated Makefile. Set this option to YES to get a
# higher quality PDF documentation.
USE_PDFLATEX = NO
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
# command to the generated LaTeX files. This will instruct LaTeX to keep
# running if errors occur, instead of asking the user for help.
# This option is also used when generating formulas in HTML.
LATEX_BATCHMODE = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
# The RTF output is optimised for Word 97 and may not look very pretty with
# other RTF readers or editors.
GENERATE_RTF = NO
# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `rtf' will be used as the default path.
RTF_OUTPUT =
# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
# RTF documents. This may be useful for small projects and may help to
# save some trees in general.
COMPACT_RTF = NO
# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
# will contain hyperlink fields. The RTF file will
# contain links (just like the HTML output) instead of page references.
# This makes the output suitable for online browsing using WORD or other
# programs which support those fields.
# Note: wordpad (write) and others do not support links.
RTF_HYPERLINKS = NO
# Load stylesheet definitions from file. Syntax is similar to doxygen's
# config file, i.e. a series of assigments. You only have to provide
# replacements, missing definitions are set to their default value.
RTF_STYLESHEET_FILE =
# Set optional variables used in the generation of an rtf document.
# Syntax is similar to doxygen's config file.
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
# generate man pages
GENERATE_MAN = NO
# The MAN_OUTPUT tag is used to specify where the man pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `man' will be used as the default path.
MAN_OUTPUT =
# The MAN_EXTENSION tag determines the extension that is added to
# the generated man pages (default is the subroutine's section .3)
MAN_EXTENSION =
# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
# then it will generate one additional man file for each entity
# documented in the real man page(s). These additional files
# only source the real man page, but without them the man command
# would be unable to find the correct page. The default is NO.
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
# If the GENERATE_XML tag is set to YES Doxygen will
# generate an XML file that captures the structure of
# the code including all documentation. Note that this
# feature is still experimental and incomplete at the
# moment.
GENERATE_XML = NO
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
# evaluate all C-preprocessor directives found in the sources and include
# files.
ENABLE_PREPROCESSING = YES
# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
# names in the source code. If set to NO (the default) only conditional
# compilation will be performed. Macro expansion can be done in a controlled
# way by setting EXPAND_ONLY_PREDEF to YES.
MACRO_EXPANSION = NO
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
# PREDEFINED and EXPAND_AS_PREDEFINED tags.
EXPAND_ONLY_PREDEF = NO
# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
# in the INCLUDE_PATH (see below) will be search if a #include is found.
SEARCH_INCLUDES = YES
# The INCLUDE_PATH tag can be used to specify one or more directories that
# contain include files that are not input files but should be processed by
# the preprocessor.
INCLUDE_PATH =
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
# directories. If left blank, the patterns specified with FILE_PATTERNS will
# be used.
INCLUDE_FILE_PATTERNS =
# The PREDEFINED tag can be used to specify one or more macro names that
# are defined before the preprocessor is started (similar to the -D option of
# gcc). The argument of the tag is a list of macros of the form: name
# or name=definition (no spaces). If the definition and the = are
# omitted =1 is assumed.
PREDEFINED =
# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
# The macro definition that is found in the sources will be used.
# Use the PREDEFINED tag if you want to use a different macro definition.
EXPAND_AS_DEFINED =
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
# The TAGFILES tag can be used to specify one or more tagfiles.
TAGFILES =
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads.
GENERATE_TAGFILE =
# If the ALLEXTERNALS tag is set to YES all external classes will be listed
# in the class index. If set to NO only the inherited external classes
# will be listed.
ALLEXTERNALS = NO
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of `which perl').
PERL_PATH =
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz, a graph visualization
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
HAVE_DOT = YES
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect inheritance relations. Setting this tag to YES will force the
# the CLASS_DIAGRAMS tag to NO.
CLASS_GRAPH = YES
# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect implementation dependencies (inheritance, containment, and
# class references variables) of the class with other documented classes.
COLLABORATION_GRAPH = YES
# If set to YES, the inheritance and collaboration graphs will show the
# relations between templates and their instances.
TEMPLATE_RELATIONS = YES
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
# tags are set to YES then doxygen will generate a graph for each documented
# file showing the direct and indirect include dependencies of the file with
# other documented files.
INCLUDE_GRAPH = YES
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
# documented header file showing the documented files that directly or
# indirectly include this file.
INCLUDED_BY_GRAPH = YES
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
# will graphical hierarchy of all classes instead of a textual one.
GRAPHICAL_HIERARCHY = YES
# The tag DOT_PATH can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found on the path.
DOT_PATH =
# The DOTFILE_DIRS tag can be used to specify one or more directories that
# contain dot files that are included in the documentation (see the
# \dotfile command).
DOTFILE_DIRS =
# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
# this value, doxygen will try to truncate the graph, so that it fits within
# the specified constraint. Beware that most browsers cannot cope with very
# large images.
MAX_DOT_GRAPH_WIDTH = 1024
# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
# this value, doxygen will try to truncate the graph, so that it fits within
# the specified constraint. Beware that most browsers cannot cope with very
# large images.
MAX_DOT_GRAPH_HEIGHT = 1024
# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
# generate a legend page explaining the meaning of the various boxes and
# arrows in the dot generated graphs.
GENERATE_LEGEND = YES
# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
# remove the intermedate dot files that are used to generate
# the various graphs.
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
# The SEARCHENGINE tag specifies whether or not a search engine should be
# used. If set to NO the values of all tags below this one will be ignored.
SEARCHENGINE = NO
# The CGI_NAME tag should be the name of the CGI script that
# starts the search engine (doxysearch) with the correct parameters.
# A script with this name will be generated by doxygen.
CGI_NAME =
# The CGI_URL tag should be the absolute URL to the directory where the
# cgi binaries are located. See the documentation of your http daemon for
# details.
CGI_URL =
# The DOC_URL tag should be the absolute URL to the directory where the
# documentation is located. If left blank the absolute path to the
# documentation, with file:// prepended to it, will be used.
DOC_URL =
# The DOC_ABSPATH tag should be the absolute path to the directory where the
# documentation is located. If left blank the directory on the local machine
# will be used.
DOC_ABSPATH =
# The BIN_ABSPATH tag must point to the directory where the doxysearch binary
# is installed.
BIN_ABSPATH =
# The EXT_DOC_PATHS tag can be used to specify one or more paths to
# documentation generated for other projects. This allows doxysearch to search
# the documentation for these projects as well.
EXT_DOC_PATHS =
Netxx-0.3.2/docs/doxygen/Makefile 0000644 0001750 0001750 00000000177 12173720353 016151 0 ustar daniel daniel PROJECT_NAME=netxx
PROJECT_PATH=${PWD}/../../
DOXYGEN_DIR=docs/doxygen
.include "${HOME}/develop/project-xslt/etc/doxygen.mk"
Netxx-0.3.2/docs/TODO 0000644 0001750 0001750 00000002564 12173720353 013526 0 ustar daniel daniel Todo List
Todo Before 1.0.0 Release
* Remove any calls to malloc with calls to new char[]. (Peer.cxx).
* use SUN_LEN instead of sizeof for AF_LOCAL;
* Separate the inet_ntop and inet_pton implementations into their own
files.
* Have a separate file for OS stuff, like os_starup, os_finish,
os_get_error, os_set_error.
* Clean up documentation and make more complete.
* Add Solaris >= 8 /dev/poll support to the Probe class.
* Add thread callbacks for OpenSSL.
* Call THREADS_init() if initializing OpenSSL.
* Add more callbacks to TLS::Context so that developers can better
customize TLS behavior.
* Verify what WSAETIMEDOUT and WSAEMSGSIZE mean.
* Optimize Netxx::Netbuf::xsputn().
* Add support for the FreeBSD kqueue(2) function in Probe_impl.
* Should Netxx::Peer::operator<< print out something different for
AF_LOCAL?
* Should we allow some way to get user credentials from a local domain
socket?
* TLS::handle_shutdown should be more robust and support non-blocking
sockets.
* How should we handle file permissions for local domain sockets? Right
now we set them to 0666. There should be some way for the developer to
override this. Maybe using a fake port, e.g., /some/file:0600?
* Add another callback to the Context class so that we can verify certs.
Netxx-0.3.2/docs/manual/ 0000755 0001750 0001750 00000000000 12173720372 014305 5 ustar daniel daniel Netxx-0.3.2/docs/manual/README 0000644 0001750 0001750 00000000317 12173720353 015165 0 ustar daniel daniel How to build on FreeBSD
Install the /usr/ports/textproc/docproject port
make
How to build on RedHat Linux 7.3 Workstation:
cd /usr/share/sgml
ln -s openjade-* openjade
pmake PREFIX=/usr
Netxx-0.3.2/docs/manual/get_started.xml 0000644 0001750 0001750 00000011461 12173720353 017336 0 ustar daniel daniel Getting Started with Netxx
Building Netxx
The following instructions will show you how to compile Netxx on most platforms.
Building on Unix
To build Netxx from the command line of a Unix-like operating system you use the configure.pl
perl script. There are various command line options that can be given to configure.pl to change
various compile time settings. You should begin by reviewing the available options by running
./configure.pl --help.
Once you know which command line options you want to give to configure.pl you can run it.
First, it will check your build environment to verify that you have the proper tools to build Netxx. After that, it will
generate the make-files for your system. When configure.pl is done you can run the
make program to build Netxx.
After Netxx is built, you can install the library and header files. This is done with the make
program and the install target.
Building on MacOS X
Building Netxx on MacOS X is similar to building it on Unix. You can follow the instructions for building on Unix if
you wish. Either way, you need to install the Developer Tools from Apple.
There is a shell script in build/macosx called configure.sh. When you run
that script the configure.pl perl script will be run with some good default values. After it is
finished, you can build Netxx using the make program.
Building on Windows
The following instructions apply to users of Microsoft Visual Studio. If you want to build Netxx under cygwin, follow
the directions for building on Unix.
There is a MSVC workspace file in build/msvc that can be used to build Netxx on Windows. Open the
Netxx.dsw workspace file. Once the workspace is loaded, pull down the Build
menu and choose the Batch Build... menu item. A dialog box will appear, click the
Rebuild All button.
Learning the Netxx API
The fastest way to learn how to use Netxx is to review the included example programs. Netxx comes with many simple and
easy to understand example programs such as an echo client/server and daytime client/server.
For complete API reference, you should take a look at the class reference appendix of the Netxx manual or the doxygen
generated web pages. Even with these resources, the best place to hang out is in the Netxx header files.
Linking with Netxx
At some point you are going to need to link with the Netxx library. If you are on a Unix-like operating system you can
use the Netxx-config shell script. This script can be used to give command line options to your
compiler and linker.
It also provides a way to abstract yourself from the operating system. Some operating systems require you to link
TCP/IP enabled applications with a socket library. The Netxx-config script will automatically supply
the correct libraries to the linker, including the OpenSSL library if necessary.
The Netxx-config script can also be helpful to figure out the version of the installed Netxx
library. There is also a little hint in the version string, if it ends with -TLS you know it is
safe to use the Netxx::TLS interface on this platform.
Netxx-0.3.2/docs/manual/credits.xml 0000644 0001750 0001750 00000004463 12173720353 016472 0 ustar daniel daniel Credits
Netxx it brought to you by the following people.
Peter Jones
Original designer of Netxx and project maintainer.
Ported to the Win32 platform.
Ported to the MacOS X platform.
Added TLS support via OpenSSL.
Alex Mitrofanov
Updated all the TLS code to the new internal API.
Completed Netxx::TLS::Stream so that it could act as a server.
Fixed a bug in the Netxx::TLS::Stream::read() function.
Wrote the tls_* examples.
Wrote the http_https_server example
Fixed up the new Netxx::Peer code to be more portable.
Wrote the Netxx::TLS::Certificate class.
Steve Bannister
Found and fixed a bug in the Netxx::Socket class.
Found a bug in the Netxx::StreamBase class relating to non-blocking connects.
Isaac Foraker
Answered stupid Win32 questions.
Netxx-0.3.2/docs/manual/bugs.xml 0000644 0001750 0001750 00000002065 12173720353 015771 0 ustar daniel daniel Known Bugs
The following is a list of bugs that may or may not be fixed. If
you have any questions about what still needs to be done to Netxx,
please take a look at the TODO file.
Unix Operating Systems
The Netxx::Address class uses gethostbyname and on most
unix-like operating systems that function is NOT thread
safe. I am currently looking at ways to get around this. I
know that some systems supply gethostbyname_r but not all
do.
Microsoft Windows
Of course there is no support for local domain sockets on
Win32. At some point I will add code for doing windows
pipes to simulate local domain sockets.
All Platforms
TLS Support is NOT thread safe. This will be fixed.
Netxx-0.3.2/docs/manual/changelog.xml 0000644 0001750 0001750 00000014432 12173720353 016761 0 ustar daniel daniel Revision History
Version 0.3.2
July 08, 2003
Version 0.3.2 is a bug fix release.
Fixed a bug where socket file descriptors could be leaked. Thanks goes to Steve Bannister.
Fixed a problem with building Netxx on Cygwin. Thanks goes to Sergio Ballestrero.
Updated Perl scripts to work around a bug in the Perl 5.8 regex parser. Thanks goes to Andy Chou.
Fixed a problem in the build system where Netxx could not be built on Solaris if you also wanted TLS/SSL
support. Thanks goes to James Sammut.
Fixed a major bug in non-blocking connects. Thanks goes to Steve Bannister.
Updated the build script for Mac OS X (configure.sh) so that IPv6 won't cause a problem under 10.2.
Implemented missing copy constructor, assignment operator and swap functions for Netxx::Stream. Thanks to
Sebastien Bellerive for finding this one.
Version 0.3.1
January 13, 2003
Version 0.3.1 is a bug fix release.
Made some changes to the internal Netxx::ServerBase class that fixed exception safety issues and a double
delete[] call. Thanks to Steve Bannister for finding this.
Made a small change to Netxx::Peer to allow Netxx to compile under MacOSX again.
Included errno.h on windows to define EAGAIN. Thanks to Charles Kerr for the suggestion.
The Netxx API appendix of this manual was removed. It caused the size of the manual to be too large.
Version 0.3.0
November 8th, 2002
Lots of changes, some bug fixes and some completely rewritten
classes. Most changes were made to make the API even easier to
use.
Rewrote Address class. The address class is now independent of its actual use. No more Address::Type.
Auto-detection of IPv4, IPv6 and Local Domain socket addresses. Much easier to use and makes input more
flexible.
Added Peer class to replace all the std::pair objects that were being used. Peer also replaces some of the
functionality of the old SockAddr class.
Moved some of the classes from the public include directory into the src directory. This means that the
classes are no longer usable outside of Netxx. The classes are: Socket and SockAddr.
Added a new Resolve class so that we can change the implementation of host name and service name resolution at
compile time based on the environment.
The server classes can now bind to more than one address. This allows you to either bind to all local
addresses or just specific ones.
Removed the MutliServer code and replaced with a new Probe class. The new Probe class can return the readable
and writable state of any Netxx socket based object. Updated the multi_server example code to use the new
Probe class.
Added Win32 MSVC Workspace files for compiling a Netxx static library under Win32.
Added a shell script for building a Netxx static library under MacOS X.
Added Netxx::TLS::Certificate class.
Added a default passphrase function that actually works!
Version 0.2.0
October 22, 2001
New features and some bug fixes.
Fixed bug in Socket::write that shows up only when
write(2) returns less than the buffer size
Fixed bug in call to select when timeout is 0
Added TLS classes a la OpenSSL
Moved some classes around in order to add TLS classes
Added the Netxx::Netbuf class which is a IOStreams streambuf
Added initial support for Microsoft Windows
Version 0.1.0
September 7, 2001
The Netxx code was cleaned up and moved around. The API is now
ready for a first release.
Version 0.0.0
March 1, 2001
First draft of some code put together as Netxx.
Netxx-0.3.2/docs/manual/todo.xml 0000644 0001750 0001750 00000004337 12173720353 016002 0 ustar daniel daniel Todo List
Todo Before 1.0.0 Release
Remove any calls to malloc with calls to new char[]. (Peer.cxx).
use SUN_LEN instead of sizeof for AF_LOCAL;
Separate the inet_ntop and inet_pton implementations into
their own files.
Have a separate file for OS stuff, like os_starup,
os_finish, os_get_error, os_set_error.
Clean up documentation and make more complete.
Add Solaris >= 8 /dev/poll support to the Probe class.
Add thread callbacks for OpenSSL.
Call THREADS_init() if initializing OpenSSL.
Add more callbacks to TLS::Context so that developers can
better customize TLS behavior.
Verify what WSAETIMEDOUT and WSAEMSGSIZE mean.
Optimize Netxx::Netbuf::xsputn().
Add support for the FreeBSD kqueue(2) function in
Probe_impl.
Should Netxx::Peer::operator<< print out something
different for AF_LOCAL?
Should we allow some way to get user credentials from a
local domain socket?
TLS::handle_shutdown should be more robust and support
non-blocking sockets.
How should we handle file permissions for local domain
sockets? Right now we set them to 0666. There should be some
way for the developer to override this. Maybe using a fake
port, e.g., /some/file:0600?
Add another callback to the Context class so that we can
verify certs.
Netxx-0.3.2/docs/manual/Makefile 0000644 0001750 0001750 00000011121 12173720353 015740 0 ustar daniel daniel #####################################################################
#
INPUT_FILE= manual.xml
OTHER_INPUT= readme.xml bugs.xml changelog.xml credits.xml todo.xml get_started.xml
#
#####################################################################
ONE_HTML_DIR= one-html
SEP_HTML_DIR= sep-html
POSTSCRIPT_DIR= postscript
ONE_HTML_OUT= ${ONE_HTML_DIR}/${INPUT_FILE:.xml=.html}
.if defined(FREEBSDDOC)
SEP_HTML_OUT= ${SEP_HTML_DIR}/index.html
.else
SEP_HTML_OUT= ${SEP_HTML_DIR}/book1.htm
.endif
POSTSCRIPT_OUT= ${POSTSCRIPT_DIR}/${INPUT_FILE:.xml=.ps}
PDF_OUT= ${POSTSCRIPT_DIR}/${INPUT_FILE:.xml=.pdf}
PREFIX?= /usr/local
JADE= ${PREFIX}/bin/openjade
.if defined(FREEBSDDOC)
CATALOGS+= -c ${FREEBSDDOC}/share/sgml/catalog
.endif
.if ${OSTYPE} == linux
CATALOGS+= -c ${PREFIX}/share/sgml/docbook/dsssl/modular/catalog
CATALOGS+= -c ${PREFIX}/share/sgml/sgml-iso-entities-8879.1986/catalog
CATALOGS+= -c ${PREFIX}/share/sgml/openjade/catalog
.else
CATALOGS+= -c ${PREFIX}/share/sgml/docbook/dsssl/modular/catalog
CATALOGS+= -c ${PREFIX}/share/sgml/iso8879/catalog
CATALOGS+= -c ${PREFIX}/share/sgml/docbook/4.1/catalog
CATALOGS+= -c ${PREFIX}/share/sgml/openjade/catalog
.endif
JADE_FLAGS= ${CATALOGS}
.if defined(FREEBSDDOC)
DSL_HTML= ${FREEBSDDOC}/share/sgml/default.dsl
DSL_PRINT= ${FREEBSDDOC}/share/sgml/default.dsl
HTMLFLAGS= -ioutput.html
PRINTFLAGS= -ioutput.print -ioutput.print.justify -V %two-side% -ioutput.print.twoside
PRINTFLAGS+= -ioutput.print.niceheaders -V minimal-section-labels
TEXCMDS= \RequirePackage{url}
TEXCMDS+= \def\PageTwoSide{1}
.else
DSL_HTML= ${PREFIX}/share/sgml/docbook/dsssl/modular/html/docbook.dsl
DSL_PRINT= ${PREFIX}/share/sgml/docbook/dsssl/modular/print/docbook.dsl
HTMLFLAGS=
PRINTFLAGS=
TEXCMDS=
.endif
TIDY= ${PREFIX}/bin/tidy -i -m -raw -preserve -f /dev/null
TEX= ${PREFIX}/bin/tex
DVIPS= ${PREFIX}/bin/dvips
PDFTEX= ${PREFIX}/bin/pdftex
all: ${ONE_HTML_OUT} ${SEP_HTML_OUT} ${POSTSCRIPT_OUT} ${PDF_OUT}
html: ${ONE_HTML_OUT} ${SEP_HTML_OUT}
ps: ${POSTSCRIPT_OUT}
pdf: ${PDF_OUT}
${ONE_HTML_OUT}: ${INPUT_FILE} ${OTHER_INPUT}
mkdir -p ${ONE_HTML_DIR}
cp ${INPUT_FILE} ${OTHER_INPUT} ${ONE_HTML_DIR}
(\
cd ${ONE_HTML_DIR}; \
${JADE} ${JADE_FLAGS} -V nochunks ${HTMLFLAGS} -d ${DSL_HTML} -t sgml ${INPUT_FILE} > ${INPUT_FILE:.xml=.html}; \
rm ${INPUT_FILE} ${OTHER_INPUT}; \
)
-${TIDY} ${ONE_HTML_OUT}
if test -r ${FREEBSDDOC}/share/misc/docbook.css -a ! -r docbook.css ; then \
cp ${FREEBSDDOC}/share/misc/docbook.css ${ONE_HTML_DIR}; \
fi
if test -r docbook.css ; then \
cp docbook.css ${ONE_HTML_DIR}; \
fi
${SEP_HTML_OUT}: ${INPUT_FILE} ${OTHER_INPUT}
mkdir -p ${SEP_HTML_DIR}
cp ${INPUT_FILE} ${OTHER_INPUT} ${SEP_HTML_DIR}
(\
cd ${SEP_HTML_DIR}; \
${JADE} ${JADE_FLAGS} ${HTMLFLAGS} -d ${DSL_HTML} -t sgml ${INPUT_FILE}; \
rm ${INPUT_FILE} ${OTHER_INPUT}; \
)
for file in `ls ${SEP_HTML_DIR}/*.htm?`; do \
${TIDY} $$file || echo -n; \
done
if test -r ${FREEBSDDOC}/share/misc/docbook.css -a ! -r docbook.css ; then \
cp ${FREEBSDDOC}/share/misc/docbook.css ${SEP_HTML_DIR}; \
fi
if test -r docbook.css ; then \
cp docbook.css ${SEP_HTML_DIR}; \
fi
${POSTSCRIPT_OUT}: ${INPUT_FILE} ${OTHER_INPUT}
mkdir -p ${POSTSCRIPT_DIR}
cp ${INPUT_FILE} ${OTHER_INPUT} ${POSTSCRIPT_DIR}
(\
cd ${POSTSCRIPT_DIR}; \
${JADE} ${JADE_FLAGS} -Vtex-backend ${PRINTFLAGS} -d ${DSL_PRINT} -t tex ${INPUT_FILE}; \
rm ${INPUT_FILE} ${OTHER_INPUT}; \
${TEX} "&jadetex" '${TEXCMDS} \nonstopmode\input{${INPUT_FILE:.xml=.tex}}' ${INPUT_FILE:.xml=.tex}; \
${TEX} "&jadetex" '${TEXCMDS} \nonstopmode\input{${INPUT_FILE:.xml=.tex}}' ${INPUT_FILE:.xml=.tex}; \
${TEX} "&jadetex" '${TEXCMDS} \nonstopmode\input{${INPUT_FILE:.xml=.tex}}' ${INPUT_FILE:.xml=.tex}; \
${DVIPS} -o ${INPUT_FILE:.xml=.ps} ${INPUT_FILE:.xml=.dvi}; \
)
${PDF_OUT}: ${POSTSCRIPT_OUT} ${INPUT_FILE} ${OTHER_INPUT}
(\
cd ${POSTSCRIPT_DIR}; \
${PDFTEX} "&pdfjadetex" '${TEXCMDS} \nonstopmode\input{${INPUT_FILE:.xml=.tex}}' ${INPUT_FILE:.xml=.tex}; \
${PDFTEX} "&pdfjadetex" '${TEXCMDS} \nonstopmode\input{${INPUT_FILE:.xml=.tex}}' ${INPUT_FILE:.xml=.tex}; \
${PDFTEX} "&pdfjadetex" '${TEXCMDS} \nonstopmode\input{${INPUT_FILE:.xml=.tex}}' ${INPUT_FILE:.xml=.tex}; \
)
clean:
rm -rf ${ONE_HTML_DIR} ${SEP_HTML_DIR} ${POSTSCRIPT_DIR}
INSTALL_DIR=${HOME}/htdocs/pjones/software/netxx/download/documentation/manual
install: all
mkdir -p ${INSTALL_DIR}
cp -p ${PDF_OUT} ${INSTALL_DIR}/
cp -p ${ONE_HTML_OUT} ${INSTALL_DIR}/
if [ -r ${ONE_HTML_DIR}/docbook.css ] ; then \
cp -p ${ONE_HTML_DIR}/docbook.css ${INSTALL_DIR}/; \
fi
cp -pr ${SEP_HTML_DIR} ${INSTALL_DIR}/
Netxx-0.3.2/docs/manual/manual.xml 0000644 0001750 0001750 00000005731 12173720353 016311 0 ustar daniel daniel
]>
Netxx Developers Manual
Peter
Jones
pjones@pmade.org
2002
2003
Peter Jones (http://pmade.org/pjones/)
Redistribution and use in source (SGML DocBook) and 'compiled'
forms (SGML, HTML, PDF, PostScript, RTF and so forth) with or
without modification, are permitted provided that the following
conditions are met:
Redistributions of source code (SGML DocBook) must retain
the above copyright notice, this list of conditions and the
following disclaimer as the first lines of this file
unmodified.
Redistributions in compiled form (transformed to other DTDs,
converted to PDF, PostScript, RTF and other formats) must
reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS DOCUMENTATION IS PROVIDED BY THE AUTHORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
This document describes Netxx to developers who are
going to use the library in their own projects.
The latest version of this manual can be found at
http://pmade.org/pjones/software/netxx/.
&include-readme;
&include-getstarted;
&include-todo;
&include-bugs;
&include-changelog;
&include-credits;
Netxx-0.3.2/docs/manual/readme.xml 0000644 0001750 0001750 00000003121 12173720353 016260 0 ustar daniel daniel Introduction
What is Netxx?
Netxx is a C++ network programming library. It is designed to take the pain out of programming network communications
applications. It does this by providing an easy to use and cross-platform interface. As a side effect, you get the safety
of automatic resource management and smaller, simpler code.
Features
Very clean API with total abstraction from any operating system calls.
No networking or operating system headers are used in the Netxx header files.
Appropriate use of C++ technologies such as namespaces, templates, inheritance and exceptions. All Netxx
classes are in the Netxx namespace and exceptions are used only in exceptional situations.
Includes support for TLS/SSL (via OpenSSL), IPv6 and Local/Unix Domain Sockets (on operating systems that support
them).
Cross-platform support. Netxx currently supports most flavors of Unix, Windows and MacOS X.
An IOStreams streambuf is provided so you can treat network connections just like a std::iostream.
Berkeley style license so you can do whatever you want with Netxx, including commercial use.
Netxx-0.3.2/docs/VERSION 0000644 0001750 0001750 00000000256 12173720353 014102 0 ustar daniel daniel 0.3.2 1 REL-0_3_2 2003/07/08
0.3.1 1 REL-0_3_1 2003/01/13
0.3.0 1 REL-0_3_0 2002/11/08
0.2 - REL-0_2 2001/10/22
0.1 - REL-0_1 2001/09/07
0.0 - --------- 2001/05/01
Netxx-0.3.2/include/ 0000755 0001750 0001750 00000000000 12173720372 013523 5 ustar daniel daniel Netxx-0.3.2/include/Netxx/ 0000755 0001750 0001750 00000000000 12173720372 014631 5 ustar daniel daniel Netxx-0.3.2/include/Netxx/Types.h 0000644 0001750 0001750 00000005121 12173720353 016104 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file defines some common types for Netxx.
**/
#ifndef _Netxx_Types_h_
#define _Netxx_Types_h_
// standard includes
#include
#include
namespace Netxx {
/// unsigned size type (used for object sizes)
typedef unsigned int size_type;
/// signed size type (used for objects with possible negative values)
typedef signed int signed_size_type;
/// type for representing port numbers
typedef unsigned short port_type;
/// type for representing socket file descriptors
typedef signed int socket_type;
/**
* The Netxx::Exception class is used by the Netxx library to signal
* some error condition. It is derived from std::runtime_error which is
* dervied from std::exception. This makes it suitable to only catch
* std::exception objects if you wish.
**/
struct Exception : public std::runtime_error {
Exception (const std::string &what_arg) :
std::runtime_error(what_arg) { }
}; // end Netxx::Exception
} // end Netxx namespace
#endif
Netxx-0.3.2/include/Netxx/StreamBase.h 0000644 0001750 0001750 00000016202 12173720353 017030 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the definition of the Netxx::StreamBase class.
**/
#ifndef _Netxx_StreamBase_h_
#define _Netxx_StreamBase_h_
// Netxx includes
#include
#include
#include
namespace Netxx {
// forward declarations
class Socket;
class ProbeInfo;
/**
* The Netxx::StreamBase class acts as a base class for the various stream
* classes. You cannot directly instianciate an object of this class because
* it has pure virtual funtions.
**/
class StreamBase {
public:
//####################################################################
/**
* Create a new StreamBase and set the timeout for stream operations.
*
* @param timeout The timeout to use for stream operations.
* @author Peter Jones
**/
//####################################################################
explicit StreamBase (const Timeout &timeout=Timeout());
//####################################################################
/**
* StreamBase virutal destructor. Cleanup the streambase.
*
* @author Peter Jones
**/
//####################################################################
virtual ~StreamBase (void);
//####################################################################
/**
* Set the timeout that is used for various stream operations.
*
* @param timeout The timeout to use.
* @author Peter Jones
**/
//####################################################################
void set_timeout (const Timeout &timeout);
//####################################################################
/**
* Get the current timeout value that is used for stream operations.
*
* @return The current timeout value.
* @author Peter Jones
**/
//####################################################################
const Timeout& get_timeout (void) const;
//####################################################################
/**
* Read data from the stream into the given buffer. This operation will
* place the read data into the buffer unless there is an error or
* timeout. If a stream fatal error occures an exception is throw.
*
* @param buffer The buffer to place read data into.
* @param length The avaliable size for the given buffer.
* @return Greater than 0: For the bytes read into the buffer.
* @return 0 If the peer closed the connection
* @return -1: For a timeout
* @author Peter Jones
**/
//####################################################################
virtual signed_size_type read (void *buffer, size_type length) = 0;
//####################################################################
/**
* Write data from a buffer into the stream. If a stream fatal error
* occures an exception is thrown.
*
* @param buffer The data to write to the stream.
* @param length The amount of data to use from the buffer.
* @return Greater than 0: The number of bytes written to the stream.
* @return 0 If the peer closed the connection.
* @return -1: for a timeout.
* @author Peter Jones
**/
//####################################################################
virtual signed_size_type write (const void *buffer, size_type length) = 0;
//####################################################################
/**
* Close the stream connection with the peer. After the connection is
* closed you should not use any of the other stream member functions.
*
* @author Peter Jones
**/
//####################################################################
virtual void close (void) = 0;
//####################################################################
/**
* Return the file descriptor that is being used for the stream
* connection.
*
* @return The file descriptor for this connection.
* @author Peter Jones
**/
//####################################################################
virtual socket_type get_socketfd (void) const = 0;
//####################################################################
/**
* Get information about how this StreamBase should be probed from
* the Netxx::Probe class.
*
* @return A Netxx::ProbeInfo object.
* @author Peter Jones
**/
//####################################################################
virtual const ProbeInfo* get_probe_info (void) const = 0;
protected:
//####################################################################
/**
* This protected member function is used to establish a connection with
* one of the addresses given. This function will throw an exception if
* it cannot make a connection with any of the given addresses.
*
* @param socket On successful return this will be the socket for the conection
* @param address The list of addresses to try
* @author Peter Jones
**/
//####################################################################
void make_connection (Socket &socket, const Address &address);
//####################################################################
/**
* Used by the stream classes so they can implement a swap() member
* function.
*
* @param other The other StreamBase to swap with.
* @author Peter Jones
**/
//####################################################################
void swap_base (StreamBase &other);
private:
Timeout timeout_;
}; // end Netxx::StreamBase class
} // end Netxx namespace
#endif
Netxx-0.3.2/include/Netxx/Probe.h 0000644 0001750 0001750 00000016416 12173720353 016060 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the defintion of the Netxx::Probe class.
**/
#ifndef _Netxx_Probe_h_
#define _Netxx_Probe_h_
// Netxx includes
#include
#include
#include
// standard includes
#include
#include
namespace Netxx {
/**
* The Netxx::Probe class is a wrapper around one of the Netxx probe
* classes. The reason that we have a wrapper is because most operating
* systems support select(2) but some also support more advanced APIs like
* kqueue(2) or /dev/poll.
**/
class Probe {
public:
/*
* Bitmask for telling Probe exactly what you want and for testing the
* return value from Probe::ready().
*/
enum ReadyType {
ready_none = 0x000000, ///< Nothing or Everything depeding on the context
ready_read = 0x000001, ///< Readable
ready_write = 0x000002, ///< Writable
ready_oobd = 0x000004 ///< Readable Out-of-band Data
};
/// type for holding the bitmask
typedef unsigned int ready_type;
/// type returned from ready()
typedef std::pair result_type;
//####################################################################
/**
* Construct a new Netxx::Probe object.
*
* @author Peter Jones
**/
//####################################################################
Probe (void);
//####################################################################
/**
* Netxx::Probe copy constructor.
*
* @param other The other Probe object to copy from.
* @author Peter Jones
**/
//####################################################################
Probe (const Probe &other);
//####################################################################
/**
* Netxx::Probe assignment operator.
*
* @param other The other Probe object to copy from.
* @return *this.
* @author Peter Jones
**/
//####################################################################
Probe& operator= (const Probe &other);
//####################################################################
/**
* Swap this Probe and another one. Similar to std::swap().
*
* @param other The other Probe to swap with.
* @author Peter Jones
**/
//####################################################################
void swap(Probe &other);
//####################################################################
/**
* Netxx::Probe destructor.
*
* @author Peter Jones
**/
//####################################################################
~Probe (void);
//####################################################################
/**
* Clear the Probe. All objects will be removed from the Probe and it
* will be in a brand-new like state.
*
* @author Peter Jones
**/
//####################################################################
void clear (void);
//####################################################################
/**
* Preform the probe. This function will block until either some data is
* ready or the given timeout expires. You may also supply a bitmask for
* the type of data you want in this probe.
*
* @param timeout How long to wait for data. Can be a NULL timeout to block until probe data is avaliable.
* @param rt A bitmask to control what is returned. ready_none means all data in this context.
* @return a std::pair where first is the ready socket and second is a bitmask to tell you what it is ready for.
* @return a std::pair with first set to -1 to signal a timeout.
* @author Peter Jones
**/
//####################################################################
result_type ready (const Timeout &timeout=Timeout(), ready_type rt=ready_none);
//####################################################################
/**
* Add an object to the Probe. The object must support the
* Netxx::ProbeInfo class. All Netxx classes such as Stream and Datagram
* support the ProbeInfo class.
*
* You can optionally give a bitmask that will tell Probe what type of
* data to probe for. The default is to probe for all data. In this
* case, ready_none means probe for all data.
*
* @param t The object to add to the Probe.
* @param rt A bitmask that tells Probe what to probe for.
* @author Peter Jones
**/
//####################################################################
template void add (const T &t, ready_type rt=ready_none) {
// implemented inline to work around bug in MSVC
const ProbeInfo *pi = t.get_probe_info();
std::vector::const_iterator i=pi->get_sockets().begin(), end=pi->get_sockets().end();
for (; i!=end; ++i) { if (pi->needs_pending_check()) add_socket(pi, *i, rt); else add_socket(*i, rt); }
}
//####################################################################
/**
* Remove the given object from the Probe.
*
* @param t The object to remove from the Probe.
* @author Peter Jones
**/
//####################################################################
template void remove (const T &t) {
// implemented inline to work around bug in MSVC
const ProbeInfo *pi = t.get_probe_info();
std::vector::const_iterator i=pi->get_sockets().begin(), end=pi->get_sockets().end();
for (; i!=end; ++i) remove_socket(*i);
}
private:
void add_socket (socket_type socketfd, ready_type rt);
void add_socket (const ProbeInfo *pi, socket_type socketfd, ready_type rt);
void remove_socket (socket_type socketfd);
struct pimpl; pimpl *pimpl_;
}; // end Probe class
} // end Netxx namespace
#endif
Netxx-0.3.2/include/Netxx/SockOpt.h 0000644 0001750 0001750 00000010127 12173720353 016364 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the definition of the Netxx::SockOpt class.
**/
#ifndef _Netxx_SockOpt_h_
#define _Netxx_SockOpt_h_
// Netxx includes
#include
namespace Netxx {
/**
* The Netxx::SockOpt class is used to set general socket options.
**/
class SockOpt {
public:
//####################################################################
/**
* Construct a new Netxx::SockOpt class and link it with the given
* socket file descriptor. If you set the revert flag to true, any
* options that you set for the socket will be reversed when this
* SockOpt class is destroyed.
*
* @param socketfd The socket file descriptor to set options for.
* @param revert Whether or not to revert in the destructor.
* @author Peter Jones
**/
//####################################################################
explicit SockOpt (socket_type socketfd, bool revert=false);
//####################################################################
/**
* Netxx::SockOpt class destructor. The destructor will possibly revert
* the socket back to its original state if the revert flag was true in
* the constructor.
*
* @author Peter Jones
**/
//####################################################################
~SockOpt (void);
//####################################################################
/**
* Set the socket to non-blocking. This will cause the read and write
* operations to return with a timeout (-1) if the operation could not
* be fullfilled imediatly.
*
* @return True if the socket was set to non-blocking.
* @return False if there was some error setting the socket to non-blocking
* @author Peter Jones
**/
//####################################################################
bool set_non_blocking (void);
//####################################################################
/**
* Set the socket option that allows you to reuse an address/port pair
* even if the state for that pair is TIMED_WAIT.
*
* @return True if the address could be reused.
* @return False if the address could not be reused.
* @author Peter Jones
**/
//####################################################################
bool set_reuse_address (void);
private:
socket_type socket_;
bool revert_;
struct pimpl; pimpl *pimpl_;
SockOpt (const SockOpt&);
SockOpt& operator= (const SockOpt&);
}; // end Netxx::SockOpt class
} // end Netxx namespace
#endif
Netxx-0.3.2/include/Netxx/Datagram.h 0000644 0001750 0001750 00000023621 12173720353 016525 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the definition of the Netxx::Datagram class.
**/
#ifndef _Netxx_Datagram_h_
#define _Netxx_Datagram_h_
// Netxx includes
#include
#include
#include
// standard includes
#include
#include
namespace Netxx {
// forward declarations
class ProbeInfo;
/**
* The Netxx::Datagram class is a simple wrapper class for sending
* datagrams. It supports both connected and unconnected datagram sockets.
**/
class Datagram {
public:
/// the type returned from Datagram::receive()
typedef std::pair receive_type;
//####################################################################
/**
* Construct a new Netxx::Datagram object. If you use this constructor
* you must use the send() and receive() member functions instead of the
* read() and write() member functions.
*
* @param timeout An optional timeout for datagram operations.
* @author Peter Jones
**/
//####################################################################
explicit Datagram (const Timeout &timeout=Timeout());
//####################################################################
/**
* Construct a new Netxx::Datagram object and connect it to the given
* peer. Connected Datagram objects can use the read() and write()
* member functions. Any data send or received will be to/from the
* connected peer.
*
* @param connect_to The peer to connect to.
* @param timeout An optional timeout for datagram operations.
* @author Peter Jones
**/
//####################################################################
explicit Datagram (const Address &connect_to, const Timeout &timeout=Timeout());
//####################################################################
/**
* Construct a new Netxx::Datagram object and connect it to the given
* peer name and port number. The peer name and port number are given to
* the Netxx::Address so please see that documentation for more info.
*
* Connected Datagram objects can use the read() and write() member
* functions. Any data send or received will be to/from the connected
* peer.
*
* @param peer_name The name of the peer to connect to with optional port number.
* @param default_port The port to use if none is given in peer_name.
* @param timeout An optional timeout to use for datagram operations.
* @see Netxx::Address
* @author Peter Jones
**/
//####################################################################
Datagram (const char *peer_name, port_type default_port, const Timeout &timeout=Timeout());
//####################################################################
/**
* Create a datagram object using an already existing socket file
* descriptor. The responsiblity for the socket will be transfered to
* the new datagram object. You can remove responsibility by calling the
* release() member function.
*
* @param socketfd The file descriptor for the socket to take ownership of.
* @param timeout An optional timeout for datagram operations.
* @author Peter Jones
**/
//####################################################################
explicit Datagram (socket_type socketfd, const Timeout &timeout=Timeout());
//####################################################################
/**
* Class destructor. Clean up after the datagram by closing the socket
* if necessary.
*
* @author Peter Jones
**/
//####################################################################
~Datagram (void);
//####################################################################
/**
* Send data to a specific peer address. You cannot use this function if
* you created the datagram object with the connecting constructor. This
* function will throw an exception if there are any errors.
*
* @param peer The peer to send the data to.
* @param buffer The buffer to send to the peer.
* @param length The size of the buffer.
* @return Greater than or equal to 0: The number of bytes sent to the peer.
* @return -1: A timeout occured.
* @author Peter Jones
**/
//####################################################################
signed_size_type send (const Peer &peer, const void *buffer, size_type length);
//####################################################################
/**
* Receive data from any peer. The peer that sent that data will be
* returned in a std::pair. This function will throw an exception if
* an error occures. You can only use this function if you did not use
* the connecting constructor.
*
* @param buffer A place to store the incoming datagram message.
* @param length The size of the buffer.
* @return receive_type.first greater than or equal to 0: The number of bytes that were placed in the buffer.
* @return receive_type.first == -1: A timeout occured.
* @author Peter Jones
**/
//####################################################################
receive_type receive (void *buffer, size_type length);
//####################################################################
/**
* Write data to the connected peer. You can only use this function if
* you used the connecting constructor. An exception will be thrown if
* an error occures.
*
* @param buffer The buffer that contains the messeage to send to the peer.
* @param length The size of the buffer.
* @return Greater than or equal to 0: The number of bytes sent to the peer.
* @return -1 A timeout occured.
* @author Peter Jones
**/
//####################################################################
signed_size_type write (const void *buffer, size_type length);
//####################################################################
/**
* Read data from a connected peer into a buffer. You can only call this
* function if you used the connecting constructor. An exception will be
* thrown if an error occures.
*
* @param buffer The place to store the received message from the peer.
* @param length The size of the buffer.
* @return Greater than or equal to 0:The number of bytes placed in your buffer.
* @return -1 A timeout occured.
* @author Peter Jones
**/
//####################################################################
signed_size_type read (void *buffer, size_type length);
//####################################################################
/**
* Get the file descriptor for the socket this Datagram object is using.
*
* @return The current socket file descriptor.
* @author Peter Jones
**/
//####################################################################
socket_type get_socketfd (void) const;
//####################################################################
/**
* Close the socket that the datagram object is using if it is open.
* This is normally done by the datagram class destructor.
*
* @author Peter Jones
**/
//####################################################################
void close (void);
//####################################################################
/**
* Release control of the socket file descriptor that is being used.
* This will prevent the destructor from closing the socket. Once you
* call release you must make sure that some other object takes control
* of the file descriptor or it could be leaked.
*
* @author Peter Jones
**/
//####################################################################
void release (void);
//####################################################################
/**
* Get information about how Datagram objects should be used with the
* Netxx::Probe class.
*
* @return A Netxx::ProbeInfo object.
* @author Peter Jones
**/
//####################################################################
const ProbeInfo* get_probe_info (void) const;
private:
struct pimpl; pimpl *pimpl_;
Datagram (const Datagram&);
Datagram& operator= (const Datagram&);
}; // end Netxx::Datagram class
} // end Netxx namespace
#endif
Netxx-0.3.2/include/Netxx/StreamServer.h 0000644 0001750 0001750 00000012151 12173720353 017423 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the definition of the Netxx::StreamServer class.
**/
#ifndef _Netxx_StreamServer_h_
#define _Netxx_StreamServer_h_
// Netxx includes
#include
#include
#include
#include
namespace Netxx {
// forward declaration
class ProbeInfo;
class ServerBase;
/**
* The Netxx::StreamServer class is used for stream based servers like TCP
* through IPv4, TCP through IPv6 and TCP through Local Domain Sockets.
**/
class StreamServer {
public:
//####################################################################
/**
* Create a StreamServer that will bind to all local addresses using the
* given port. You can also set a timeout value and a listen(2) backlog
* value.
*
* @param port The port to use on all local interfaces.
* @param timeout The timeout to use. Default is to block.
* @param listen_backlog The listen(2) backlog parameter.
* @author Peter Jones
**/
//####################################################################
StreamServer (port_type port, const Timeout &timeout=Timeout(), int listen_backlog=128);
//####################################################################
/**
* Create a StreamServer that will bind to each address given in addr.
* You can also set the timeout and listen(2) backlog value.
*
* @param addr The addresses to bind to.
* @param timeout The timeout to use. Default is to block.
* @param listen_backlog The listen(2) backlog parameter.
* @author Peter Jones
**/
//####################################################################
StreamServer (const Address &addr, const Timeout &timeout=Timeout(), int listen_backlog=128);
//####################################################################
/**
* Clean up after the StreamServer. Any sockets in use will be closed.
*
* @author Peter Jones
**/
//####################################################################
~StreamServer (void);
//####################################################################
/**
* Try to accept a connection from a Peer. The returned value will
* indicate whether or not a connection was established or a timeout
* occured. This member function will throw an exception if there is an
* error.
*
* @return A Peer that contains info about the connected peer.
* @return An invalid Peer to signal a timeout.
* @see Netxx::Peer
* @author Peter Jones
**/
//####################################################################
Peer accept_connection (void);
//####################################################################
/**
* Get information about how this StreamServer should be probed from the
* Netxx::Probe class.
*
* @return A Netxx::ProbeInfo object.
* @author Peter Jones
**/
//####################################################################
const ProbeInfo* get_probe_info (void) const;
friend bool operator== (const StreamServer &ss, socket_type fd);
friend bool operator== (socket_type fd, const StreamServer &ss);
friend bool operator!= (const StreamServer &ss, socket_type fd);
friend bool operator!= (socket_type fd, const StreamServer &ss);
private:
ServerBase *pimpl_;
StreamServer (const StreamServer&);
StreamServer& operator= (const StreamServer&);
void init (const Address &addr, int backlog);
}; // end Netxx::StreamServer class
} // end Netxx namespace
#endif
Netxx-0.3.2/include/Netxx/Timeout.h 0000644 0001750 0001750 00000011565 12173720353 016437 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the definition of the Netxx::Timeout class.
**/
#ifndef _Netxx_Timeout_h_
#define _Netxx_Timeout_h_
namespace Netxx {
/**
* The Netxx::Timeout class is used by the other Netxx classes to specifiy a
* timeout value. A timeout is broken down into seconds and microseconds.
* This class also has a default constructor for a null timeout, that is, no
* timeout.
*
* As a side note, just in case you did not know, there are one million
* microseconds in one second.
**/
class Timeout {
public:
//####################################################################
/**
* Construct a null timeout. This means that a timeout value should not
* be used at all. This is the default for most Netxx classes.
*
* @author Peter Jones
**/
//####################################################################
Timeout (void) : sec_(0), usec_(0) { }
//####################################################################
/**
* Construct a Netxx::Timeout with the given length in seconds and
* optionally the addition of the given microseconds.
*
* @param sec The number of seconds for the timeout.
* @param usec An optional number of microseconds.
* @author Peter Jones
**/
//####################################################################
explicit Timeout (long sec, long usec=0) : sec_(sec), usec_(usec) {}
//####################################################################
/**
* Set the seconds part of the timeout.
*
* @param sec The new value for the seconds field.
* @author Peter Jones
**/
//####################################################################
void set_sec (long sec)
{ sec_ = sec; }
//####################################################################
/**
* Get the seconds field of the timeout.
*
* @return The timeout's seconds field.
* @author Peter Jones
**/
//####################################################################
long get_sec (void) const
{ return sec_; }
//####################################################################
/**
* Set the microseconds field for the timeout.
*
* @param usec The microseconds to use for this timeout.
* @author Peter Jones
**/
//####################################################################
void set_usec (long usec)
{ usec_ = usec; }
//####################################################################
/**
* Get the microseconds field for this timeout.
*
* @return The timeout's microseconds field.
* @author Peter Jones
**/
//####################################################################
long get_usec (void) const
{ return usec_; }
//####################################################################
/**
* Test to see if this timeout is valid or null.
*
* @return True if this timeout has been set with a value.
* @return False if this timeout is NULL (set to zero).
* @author Peter Jones
**/
//####################################################################
operator bool (void) const
{ return sec_ || usec_; }
private:
long sec_;
long usec_;
}; // end Netxx::Timeout class
} // end Netxx namespace
#endif
Netxx-0.3.2/include/Netxx/ProbeInfo.h 0000644 0001750 0001750 00000017073 12173720353 016674 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the defintion of the Netxx::ProbeInfo class.
**/
#ifndef _Netxx_ProbeInfo_h_
#define _Netxx_ProbeInfo_h_
// Netxx includes
#include
// standard includes
#include
namespace Netxx {
/**
* The Netxx::ProbeInfo class is used to provide information to the
* Netxx::Probe class on how to probe another Netxx object. This
* implementation of the class does not do much. The entire implementation
* is inline to make most of it disapper at compile time.
*
* For Netxx objects that need custom probing, they will create their own
* ProbeInfo class and drive from this one.
**/
class ProbeInfo {
public:
/**
* The ProbeInfo::PendingType is used to signal what state a socket is
* in after a pending check.
*/
enum PendingType {
pending_none = 0x000000, ///< The socket is not ready
pending_read = 0x000001, ///< The socket is ready for reading
pending_write = 0x000002, ///< The socket is ready for writing
pending_oobd = 0x000004 ///< The socket is ready for reading OOB data.
};
/// a type for combinding different PendingType's
typedef unsigned int pending_type;
//####################################################################
/**
* Netxx::ProbeInfo Default constructor.
*
* @author Peter Jones
**/
//####################################################################
ProbeInfo (void)
{ }
//####################################################################
/**
* Construct a new ProbeInfo using a vector of sockets.
*
* @param sockets The list of sockets to use for probing.
* @author Peter Jones
**/
//####################################################################
explicit ProbeInfo (const std::vector &sockets)
: sockets_(sockets) { }
//####################################################################
/**
* Construct a new ProbeInfo using only one socket.
*
* @param socketfd The socket to probe for.
* @author Peter Jones
**/
//####################################################################
explicit ProbeInfo (socket_type socketfd)
{ add_socket(socketfd); }
//####################################################################
/**
* Copy constructor.
*
* @param other The ProbeInfo to copy from.
* @author Peter Jones
**/
//####################################################################
ProbeInfo (const ProbeInfo &other)
: sockets_(other.sockets_) { }
//####################################################################
/**
* Assignment operator.
*
* @param other The ProbeInfo to copy from.
* @return *this.
* @author Peter Jones
**/
//####################################################################
ProbeInfo& operator= (const ProbeInfo &other)
{ ProbeInfo tmp(other); swap(tmp); return *this; }
//####################################################################
/**
* Swap this ProbeInfo for another.
*
* @param other The ProbeInfo to swap with.
* @author Peter Jones
**/
//####################################################################
void swap (ProbeInfo &other)
{ sockets_.swap(other.sockets_); }
//####################################################################
/**
* Class destructor.
*
* @author Peter Jones
**/
//####################################################################
virtual ~ProbeInfo (void)
{ }
//####################################################################
/**
* Add a socket file descriptor to the list of sockets to probe.
*
* @param socketfd The socket file descriptor to add.
* @author Peter Jones
**/
//####################################################################
void add_socket (socket_type socketfd)
{ sockets_.push_back(socketfd); }
//####################################################################
/**
* Get the list of sockets that need to be probed.
*
* @return A vector that contains all the sockets to be probed.
* @author Peter Jones
**/
//####################################################################
const std::vector& get_sockets (void) const
{ return sockets_; }
//####################################################################
/**
* Reset the list of sockets to probe. Note: this will not reset the
* sockets to probe in the actual Netxx::Probe class. You should call
* Netxx::Probe::clear() as well.
*
* @author Peter Jones
**/
//####################################################################
void clear (void)
{ sockets_.clear(); }
//####################################################################
/**
* Override this function if you need special pending checks for your
* socket file descriptors.
*
* @return True if Probe should call check_pending().
* @return False if Probe should not call check_pending().
* @author Peter Jones
**/
//####################################################################
virtual bool needs_pending_check (void) const
{ return false; }
//####################################################################
/**
* Override this function to return the correct pending state for the
* given socket file descriptor. This call should be very fast and
* should NEVER EVER block!
*
* @param socket_type The socket to check pending status on.
* @param pending_type What type of pending state are we looking for.
* @return The pending state for the socket.
* @author Peter Jones
**/
//####################################################################
virtual pending_type check_pending (socket_type, pending_type) const
{ return pending_none; }
private:
std::vector sockets_;
}; // end ProbeInfo class
} // end Netxx namespace
#endif
Netxx-0.3.2/include/Netxx/Address.h 0000644 0001750 0001750 00000020411 12173720353 016364 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the definition of the Netxx::Address class.
**/
#ifndef _Netxx_Address_h_
#define _Netxx_Address_h_
// Netxx includes
#include
#include
// standard includes
#include
#include
namespace Netxx {
/**
* The Netxx::Address class is used by Netxx as a container for network
* addresses. An address can be used by a server to specify which local
* address and port to bind to. An address can also be used by a client to
* know which remote host to connect to and on which port.
*
* In Netxx, the address also specifies other connection related
* information, such as the connection protocol.
**/
class Address {
public:
/// address container type
typedef std::vector container_type;
/// address const_iterator type
typedef container_type::const_iterator const_iterator;
//####################################################################
/**
* Netxx::Address class constructor. This constructor is designed to be
* used by clients wanting the address information about a server. The
* url parameter can be a host name with or without a protocol, port
* number or path. Here are some examples: pmade.org pmade.org:80
* http://pmade.org http://pmade.org:80/index.html.
*
* Here is the order in which the port number is determined. (1) from
* the port part of the hostname as in pmade.org:80, (2) from the given
* protocol part such as http:// and (3) from the given default port.
*
* @param uri A string as described above
* @param default_port The default port number for this address
* @param use_ipv6 Allow the use of IPv6 if compiled in.
* @author Peter Jones
**/
//####################################################################
explicit Address (const char *uri, port_type default_port=0, bool use_ipv6=false);
//####################################################################
/**
* Netxx::Address class constructor. This constructor is designed to be
* used by servers when they need to specify the local addresses and
* ports to which it will bind.
*
* After the constructor is called, you will want to add addresses to
* the address list using one of the appropriate member functions such
* as add_address.
*
* @param use_ipv6 Allow the use of IPv6 if compiled in.
* @author Peter Jones
**/
//####################################################################
explicit Address (bool use_ipv6=false);
//####################################################################
/**
* Netxx::Address class destructor.
*
* @author Peter Jones
**/
//####################################################################
~Address (void);
//####################################################################
/**
* If the URI that was given in the constructor had a protocol specifier
* such as http:// this member function will return that string.
* Otherwise this function will return 0.
*
* @return The protcol string like "http" or 0.
* @author Peter Jones
**/
//####################################################################
const char* get_protocol (void) const;
//####################################################################
/**
* Get the hostname that was given in the constructor. This may be a raw
* address if that was given to the constructor.
*
* @return The hostname.
* @author Peter Jones
**/
//####################################################################
const char* get_name (void) const;
//####################################################################
/**
* Get the URI path information of that was present in the constructor.
* For example, if the given URI was pmade.org/index.html, this member
* function will return "/index.html". If no path information was given
* in the URI, this function will return 0.
*
* @return The path string or 0.
* @author Peter Jones
**/
//####################################################################
const char* get_path (void) const;
//####################################################################
/**
* This function will return the actual port number that was chosen by
* the constructor.
*
* @return The final port number for this address.
* @author Peter Jones
**/
//####################################################################
port_type get_port (void) const;
//####################################################################
/**
* Get an iterator to the first address pair.
*
* @return The address begin iterator.
* @author Peter Jones
**/
//####################################################################
const_iterator begin (void) const;
//####################################################################
/**
* Get an iterator that points one past the last address pair.
*
* @return The address end iterator.
* @author Peter Jones
**/
//####################################################################
const_iterator end (void) const;
//####################################################################
/**
* Find out how many addresses are stored in this address class.
*
* @return The number of addresses that this class is holding.
* @author Peter Jones
**/
//####################################################################
size_type size (void) const;
//####################################################################
/**
* Add another address to the list. The URI parameter follows that of
* the first constructor.
*
* @param uri The URI of the address.
* @param default_port The default port to use.
* @author Peter Jones
**/
//####################################################################
void add_address(const char *uri, port_type default_port=0);
//####################################################################
/**
* Add all local addresses to the address list. This is meant to be used
* by servers who wish to bind to all local addresses.
*
* @param port The port to use for all local addresses.
* @author Peter Jones
**/
//####################################################################
void add_all_addresses (port_type port);
private:
std::string protocol_;
std::string name_;
std::string path_;
port_type port_;
container_type addrs_;
bool ipv6_;
}; // end Netxx::Address class
} // end Netxx namespace
#endif
Netxx-0.3.2/include/Netxx/TLS/ 0000755 0001750 0001750 00000000000 12173720372 015273 5 ustar daniel daniel Netxx-0.3.2/include/Netxx/TLS/Context.h 0000644 0001750 0001750 00000015450 12173720353 017074 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the definition of the Netxx::TLS::Context class.
**/
#ifndef _Netxx_TLS_Context_h_
#define _Netxx_TLS_Context_h_
// Netxx includes
#include
namespace Netxx { namespace TLS {
// forward declarations
class Stream;
class Server;
struct context_pimpl;
/**
* The Netxx::TLS::Context class is used to hold common TLS information. It
* is needed to create TLS stream objects. You can subclass the
* Netxx::TLS::Context class to customize such things as the password
* callback.
**/
class Context {
public:
/**
* Provides a list of protocols that you can choose to support or not
* support. It is recomended that you don't support SSLv2.
*/
enum Protocol {
PROTOCOL_SSLv2, ///< SSL Version 2
PROTOCOL_SSLv3, ///< SSL Version 3
PROTOCOL_TLSv1, ///< TLS Version 1
};
//####################################################################
/**
* Construct a new Netxx::TLS::Context object and optionally initilize
* the backend TLS library. You don't want to initilize the backend TLS
* library more than once so you can give the constructor false for the
* allow_init flag.
*
* To make the Netxx::TLS::Context thread safe, you should create one
* Context object and load certificate files before you start any
* threads.
*
* @param allow_init If true, initilize the backend TLS library.
* @author Peter Jones
**/
//####################################################################
explicit Context (bool allow_init=true);
//####################################################################
/**
* Netxx::TLS::Context destructor.
*
* @author Peter Jones
**/
//####################################################################
virtual ~Context (void);
//####################################################################
/**
* Load the a certificate chain from the given file. A certificate chain
* file should contain PEM encoded certificate in chain order. Chain
* order starts from the application certificate and ends with the root
* CA certificate.
*
* @param filename The name of the file that contains the certificate chain.
* @author Peter Jones
**/
//####################################################################
void load_cert_chain (const char *filename);
//####################################################################
/**
* Load a possibly encrypted private key from the given file. If the
* file is encrypted, the password callback will be called to get the
* passphrase to decrypt the private key.
*
* @param filename The name of the file that contains the private key.
* @author Peter Jones
**/
//####################################################################
void load_private_key (const char *filename);
//####################################################################
/**
* Load a PEM encoded file that contains a list of trusted CA
* certificates.
*
* @param filename The file tht contains the CA certificates.
* @author Peter Jones
**/
//####################################################################
void load_ca_file (const char *filename);
//####################################################################
/**
* Disable support for the given protocol.
*
* @param which_protocol The protocol to remove support for.
* @author Peter Jones
**/
//####################################################################
void remove_protocol (Protocol which_protocol);
protected:
//####################################################################
/**
* Override this function so that you can handle password requests in a
* custom way. For example, you may want to open a GUI dialog and ask
* for the password. You must use this function on Win32.
*
* @param password The string to store the password in.
* @param encrypting True if the password is needed for encrypting; flase for decrypting
* @return True for success
* @return False for failure
* @author Peter Jones
**/
//####################################################################
virtual bool get_password (std::string &password, bool encrypting);
//####################################################################
/**
* Override this function to provide a custom way to seed the
* pseudorandom number generator. On platfors that don't have a
* /dev/random entropy source. This function will be called when the
* context is created (and if the allow_init flag was true) and should
* return some seed data in the passed in std::string.
*
* @param seed The place to return some seed data.
* @author Peter Jones
**/
//####################################################################
virtual void seed_prng (std::string &seed);
private:
context_pimpl *pimpl_;
friend struct context_pimpl;
friend class Stream;
friend class Server;
Context (const Context&);
Context& operator= (const Context&);
}; // end Netxx::TLS::Context class
}} // end Netxx and TLS namespace
#endif
Netxx-0.3.2/include/Netxx/TLS/Certificate.h 0000644 0001750 0001750 00000014204 12173720353 017666 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the definition of the TLS::Certificate class.
**/
#ifndef _Netxx_TLS_Certificate_h_
#define _Netxx_TLS_Certificate_h_
// standard includes
#include
namespace Netxx { namespace TLS {
/**
* The Netxx::TLS::Certificate class allows you to access information about
* an X509 certificate. You should use this so that you can verify that the
* peer you are communicating with is the one you think it is.
*/
class Certificate {
public:
//####################################################################
/**
* Create a new Netxx::TLS::Certificate. This is pretty useless for now
* because this is a pure-virtual class.
*
* @author Alex Mitrofanov
**/
//####################################################################
Certificate (void);
//####################################################################
/**
* Cleanup a Netxx::TLS::Certificate object
*
* @author Alex Mitrofanov
**/
//####################################################################
virtual ~Certificate (void);
//####################################################################
/**
* Check to see if this certificate object is valid.
*
* @return True (1) if the certificate is valid.
* @return False (0/NULL) if the certificate is NOT valid.
* @author Peter Jones
**/
//####################################################################
virtual operator void* (void) const = 0;
//####################################################################
/**
* Another way to check if this certificate object is valid.
*
* @return True if the certificate is NOT valid.
* @return False if the certificate is valid.
* @author Peter Jones
**/
//####################################################################
virtual bool operator! (void) const = 0;
//####################################################################
/**
* Get the fully qualified domain name, or the common name from the
* certificate. The FQDN is checked first, if there is no FQND,
* commonName is returned.
*
* @return The FQDN or commonName
* @return A blank string to signal error.
* @author Alex Mitrofanov
**/
//####################################################################
virtual std::string get_fqdn (void) const = 0;
//####################################################################
/**
* Get the country name from the certificate.
*
* @return The country name.
* @return A blank string to signal error.
* @author Alex Mitrofanov
**/
//####################################################################
virtual std::string get_country (void) const = 0;
//####################################################################
/**
* Get the locality name (e.g, the state name) from the certifcate.
*
* @return The locality name.
* @return A blank string to signal error.
* @author Alex Mitrofanov
**/
//####################################################################
virtual std::string get_locality (void) const = 0;
//####################################################################
/**
* Get the region name (e.g., city name) from the certificate.
*
* @return The region name.
* @return A blank string to signal error.
* @author Alex Mitrofanov
**/
//####################################################################
virtual std::string get_region (void) const = 0;
//####################################################################
/**
* Get the organization name from the certificate.
*
* @return The organization name.
* @return A blank string to signal error.
* @author Alex Mitrofanov
**/
//####################################################################
virtual std::string get_organization (void) const = 0;
//####################################################################
/**
* Get the organizational unit name from the certificate.
*
* @return The organizational unit name
* @return A blank string to signal error.
* @author Alex Mitrofanov
**/
//####################################################################
virtual std::string get_organization_unit (void) const = 0;
private:
Certificate (const Certificate&);
Certificate& operator= (const Certificate&);
}; // end Netxx::TLS::Certificate class
}} // namespace Netxx & namespace TLS
#endif
Netxx-0.3.2/include/Netxx/TLS/Stream.h 0000644 0001750 0001750 00000021360 12173720353 016700 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the definition of the Netxx::TLS::Stream class.
**/
#ifndef _Netxx_TLS_Stream_h_
#define _Netxx_TLS_Stream_h_
// Netxx includes
#include
#include
#include
namespace Netxx {
// forward declarations
class ProbeInfo;
namespace TLS {
// forward declaration
class Certificate;
struct tls_pimpl;
/**
* The Netxx::TLS::Stream class is used to send and receive data on a
* connected TLS socket. It has two constructors, one that connects to the
* given address and another that uses an already connected socket.
*
* When using the constructor that can take a socket descriptor you must
* specifiy whether the TLS::Stream should operate in server or client mode.
* This is due to the TLS protocol being a little different for a client
* than it is for a server.
**/
class Stream : public Netxx::StreamBase {
public:
/**
* The connection mode for the Netxx::TLS::Stream
*/
enum Mode {
mode_client, ///< This Netxx::TLS::Stream should act as a TLS client.
mode_server ///< This Netxx::TLS::Stream shoudl act as a TLS server.
};
//####################################################################
/**
* Construct a new Netxx::TLS::Stream object. This constructor will
* connect to the peer given in the Netxx::Address class.
*
* @param context The context to use for this stream.
* @param address The address to connect to.
* @param timeout The timeout to use for the connect and stream operations.
* @author Peter Jones
**/
//####################################################################
explicit Stream (Context &context, const Address &address, const Timeout &timeout=Timeout());
//####################################################################
/**
* Construct a new Netxx::TLS::Stream object. This constructor will
* connect to the given address. The given address string is passed to a
* Netxx::Address class.
*
* @param context The contect to use for this stream.
* @param addr The address to connect to.
* @param default_port The port to connect to if one is not given in addr.
* @param timeout The timeout to use for the connect and stream operations.
* @author Peter Jones
**/
//####################################################################
Stream (Context &context, const char *addr, port_type default_port, const Timeout &timeout=Timeout());
//####################################################################
/**
* Construct a new Netxx::TLS::Stream object and start TLS on the given
* socket file descriptor. This object will then own the socket file
* descriptor and will close it when it is done with it.
*
* A mode is needed so that the Netxx::TLS::Stream will know what parts
* of the TLS protocol to use, client or server. Default is client.
*
* @param context The TLS::Context to use for this stream.
* @param socketfd The socket file descriptor to use.
* @param mode Is this a TLS server or client?
* @param timeout The Timeout to use for stream operations.
* @author Peter Jones
**/
//####################################################################
Stream (Context &context, socket_type socketfd, Mode mode=mode_client, const Timeout &timeout=Timeout());
//####################################################################
/**
* Netxx::TLS::Stream destructor. Shutdown the TLS connection if
* necessary and clean things up.
*
* @author Peter Jones
**/
//####################################################################
~Stream (void);
//####################################################################
/**
* Read data from the TLS connection and place it into the given buffer.
* If an error occures this function will throw an exception.
*
* @param buffer The buffer to store the read data into.
* @param length The size of the given buffer.
* @return Greater than 0: The number of bytes stored in the buffer.
* @return 0: The connected peer closed the connection.
* @return -1: A timeout occured.
* @author Peter Jones
**/
//####################################################################
signed_size_type read (void *buffer, size_type length);
//####################################################################
/**
* Write data from the given buffer to the TLS conection. If an error
* occures this function will throw an exception.
*
* @param buffer The buffer to write to the connection.
* @param length The number of bytes to use from the buffer.
* @return Greater than 0: The number of bytes written to the connection.
* @return 0: The connected peer closed the connection.
* @return -1: A timeout occured.
* @author Peter Jones
**/
//####################################################################
signed_size_type write (const void *buffer, size_type length);
//####################################################################
/**
* Close the connection. Once you do this you can't call read or write
* anymore. This is normally done by the destructor.
*
* @author Peter Jones
**/
//####################################################################
void close (void);
//####################################################################
/**
* Get the connected peer's certificate.
*
* @return A valid certificate if the peer gave one to you
* @return An invalid certificate if the peer does not have one
* @author Alex Mitrofanov
**/
//####################################################################
const Certificate& get_peer_cert (void) const;
//####################################################################
/**
* Get the certificate for the issuer of the connected peer's
* certificate.
*
* @return A valid certificate if the peer gave one and it was signed by an issuer
* @return An invalid certificate if there was no peer cert or no issuer
* @author Alex Mitrofanov
**/
//####################################################################
const Certificate& get_issuer_cert (void) const;
//####################################################################
/**
* Return the current socket file descriptor in use.
*
* @author Alex Mitrofanov
**/
//####################################################################
socket_type get_socketfd (void) const;
//####################################################################
/**
* Get information about how this TLS::Stream should be probed from the
* Netxx::Probe class.
*
* @return A Netxx::ProbeInfo object.
* @author Peter Jones
**/
//####################################################################
const ProbeInfo* get_probe_info (void) const;
private:
tls_pimpl *pimpl_;
Stream (const Stream&);
Stream& operator= (const Stream&);
}; // end Netxx::TLS::Stream class
}} // end Netxx and TLS namespaces
#endif
Netxx-0.3.2/include/Netxx/Peer.h 0000644 0001750 0001750 00000017265 12173720353 015707 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the definition of the Netxx::Peer class.
**/
#ifndef _Netxx_Peer_h_
#define _Netxx_Peer_h_
// Netxx includes
#include
// standard includes
#include
namespace Netxx {
/**
* The Netxx::Peer class holds information about the Peer you are talking
* and/or connected to.
**/
class Peer {
public:
//####################################################################
/**
* Default constructor for an invalid peer.
*
* @author Peter Jones
**/
//####################################################################
Peer (void);
//####################################################################
/**
* Constructor that takes the address of the peer.
*
* @param addr The string form of the peer's address
* @param port The peer's port.
* @param saddr The peer address struct.
* @param saddr_size The size of saddr.
* @author Peter Jones
**/
//####################################################################
Peer (const char *addr, port_type port, void *saddr, size_type saddr_size);
//####################################################################
/**
* Create a new Peer where the socket file descriptor used to
* communicate with the peer is given in socketfd and the sockaddr
* struct for the peer is given in saddr.
*
* @param socketfd The socket file descriptor for the peer.
* @param saddr The sockaddr struct for the peer.
* @param saddr_size The size of the saddr struct.
* @author Peter Jones
**/
//####################################################################
Peer (socket_type socketfd, void *saddr, size_type saddr_size);
//####################################################################
/**
* Copy constructor.
*
* @param other The other Peer class to copy from.
* @author Peter Jones
**/
//####################################################################
Peer (const Peer &other);
//####################################################################
/**
* Assignment operator.
*
* @param other The other Peer class to assign from.
* @author Peter Jones
**/
//####################################################################
Peer& operator= (const Peer &other);
//####################################################################
/**
* Swap this Peer class with another one.
*
* @param other Peer class to swap with.
* @author Peter Jones
**/
//####################################################################
void swap (Peer &other);
//####################################################################
/**
* Class destructor.
*
* @author Peter Jones
**/
//####################################################################
~Peer (void);
//####################################################################
/**
* Get the string version of the address of the peer.
*
* @return The address of the peer.
* @author Peter Jones
**/
//####################################################################
const char* get_address (void) const;
//####################################################################
/**
* Get the port number for the peer.
*
* @return The port number of the peer.
* @author Peter Jones
**/
//####################################################################
port_type get_port (void) const;
//####################################################################
/**
* Get the local port number for the peer.
*
* @return The local port number of the peer.
* @author Alex Mitrofanov
**/
//####################################################################
port_type get_local_port (void) const;
//####################################################################
/**
* Get the socket file descriptor for this peer. This member function
* will return -1 if there is no socket file descriptor for this peer.
*
* @return The socket file descriptor or -1.
* @author Peter Jones
**/
//####################################################################
socket_type get_socketfd (void) const;
//####################################################################
/**
* Test to see if a peer is valid.
*
* @return True if the peer is valid.
* @return False if the peer is invalid.
* @author Peter Jones
**/
//####################################################################
operator bool (void) const;
//####################################################################
/**
* Get the sockaddr struct as a void pointer if this is a valid Peer
* object.
*
* @return A void pointer to the sockaddr struct.
* @return 0 If this Peer is invalid.
* @author Peter Jones
**/
//####################################################################
const void* get_sa (void) const;
//####################################################################
/**
* Get the size of the sockaddr struct if this is a valid Peer object.
*
* @return The size of the sockaddr struct.
* @return 0 If this Peer is invalid.
* @author Peter Jones
**/
//####################################################################
size_type get_sa_size (void) const;
private:
bool okay_;
std::string addr_;
port_type port_;
socket_type socketfd_;
void *sockaddr_;
size_type sockaddr_size_;
}; // end Netxx::Peer class
//####################################################################
/**
* Insert the string form of the peer into the given stream.
*
* @param stream The stream to insert the peer into.
* @param peer The peer to insert.
* @return The stream from the first param.
* @author Peter Jones
**/
//####################################################################
std::ostream& operator<< (std::ostream &stream, const Peer &peer);
} // end Netxx namespace
#endif
Netxx-0.3.2/include/Netxx/Stream.h 0000644 0001750 0001750 00000023602 12173720353 016237 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the definition of the Netxx::Stream class.
**/
#ifndef _Netxx_Stream_h_
#define _Netxx_Stream_h_
// Netxx includes
#include
#include
namespace Netxx {
// forward declarations
class ProbeInfo;
/**
* The Netxx::Stream class is used to establish a connection with a peer.
* The peer to connect to is listed in a Netxx::Address class. The peer may
* have more than one address in the Netxx::Address and the Netxx::Stream
* class will connect to the first one possible.
*
* This class is mainly for a 'client' application since it makes the
* connection to a given peer. To make is useful in a server application,
* this class also has a constructor that you can use to communicate with a
* client that was returned from a call to accept_connection().
**/
class Stream : public StreamBase {
public:
//####################################################################
/**
* Construct a new Netxx::Stream and connect to the given peer. The
* first address in the Netxx::Address class that works will be the one
* the Stream object is connected to. If the Stream object cannot
* connect to any of the address an exception is trown.
*
* If a timeout is given, it will be used for all stream operations,
* including the initial connection to the peer.
*
* @param address The list of addresses for the peer.
* @param timeout An optional timeout to use for all operations.
* @author Peter Jones
**/
//####################################################################
explicit Stream (const Address &address, const Timeout &timeout=Timeout());
//####################################################################
/**
* Construct a new Netxx::Stream without a Netxx::Address. Instead given
* a char* that holds the name of the peer. This name will be passed to
* the Netxx::Address constructor along with the given default port
* number.
*
* @param uri The name of the peer to connect to in a possible URI format.
* @param default_port The port to use if the given URI does not have one.
* @param timeout An optional timeout to use for all operations.
* @see Netxx::Address
* @author Peter Jones
**/
//####################################################################
explicit Stream (const char *uri, port_type default_port=0, const Timeout &timeout=Timeout());
//####################################################################
/**
* Construct a new Netxx::Stream and take over an already established
* connection. This Stream object will then own the connection socket
* and will close it in its destructor.
*
* This is useful for server applications so that they can use a
* Netxx::Stream object to communicate with a new client that was
* returned from Netxx::StreamServer::accept_connection().
*
* @param socketfd The file descriptor for the socket to own.
* @param timeout An optional timeout to use for all operations.
* @author Peter Jones
**/
//####################################################################
explicit Stream (socket_type socketfd, const Timeout &timeout=Timeout());
//####################################################################
/**
* Netxx::Stream copy constructor. I can't see how this would be very
* useful but it is provided for safety and completeness. The copy
* constructor will cause a copy of the socket to be made.
*
* @param other The other Netxx::Stream to copy from.
* @author Peter Jones
**/
//####################################################################
Stream (const Stream &other);
//####################################################################
/**
* Assignement operator. I can't see how this would be very useful but
* it is provided for safety and completeness. This function will
* preform a copy of the give Netxx::Stream object via the Netxx::Stream
* copy constructor.
*
* @param other The other Netxx::Stream to copy from.
* @author Peter Jones
**/
//####################################################################
Stream& operator= (const Stream &other);
//####################################################################
/**
* Exchange connection information with another Netxx::Stream. This is
* similar to std::swap().
*
* @param other The other Netxx::Stream object to swap with.
* @author Peter Jones
**/
//####################################################################
void swap (Stream &other);
//####################################################################
/**
* Netxx::Stream destructor. Close the connection with the peer if there
* is one.
*
* @author Peter Jones
**/
//####################################################################
~Stream (void);
//####################################################################
/**
* Read data from the connected peer and place then in the given buffer.
* If an error occures this function will throw an exception. If a
* timeout occures (only if you set a timeout) then -1 is returned.
*
* It is possible for this function to return -1 if you did not set a
* timeout. This would happen if you had set the socket for this
* connection to non-blocking via the Netxx::SockOpt class.
*
* @param buffer The buffer to store the read bytes into.
* @param length The size of the given buffer.
* @return Greater than 0: The number of bytes read from the peer and placed into your buffer.
* @return 0: The peer closed the connection.
* @return -1: A timeout occured.
* @see Netxx::SockOpt
* @author Peter Jones
**/
//####################################################################
signed_size_type read (void *buffer, size_type length);
//####################################################################
/**
* Write data from the given buffer to the connected peer. If an error
* occures this function will throw an exception. If a timeout occures
* (only if you set a timeout) then -1 is returned.
*
* It is possible for this function to return -1 if you did not set a
* timeout. This would happen if you had set the socket for this
* connection to non-blocking via the Netxx::SockOpt class.
*
* @param buffer The buffer to take the data from and send to the peer.
* @param length The amount of data to use from the buffer.
* @return Greater than 0: The number of bytes that were sent to the peer.
* @return 0: The peer closed the connection.
* @return -1: A timeout occured.
* @see Netxx::SockOpt
* @author Peter Jones
**/
//####################################################################
signed_size_type write (const void *buffer, size_type length);
//####################################################################
/**
* Close the connection to the peer. Once the connection is closed you
* should not preform any other operations on this object. This function
* is normally called from the destructor.
*
* @author Peter Jones
**/
//####################################################################
void close (void);
//####################################################################
/**
* Return the socket file descriptor used for the peer connection. This
* is useful for calls to the Netxx::SockOpt class, as well as others.
*
* @return The socket file descriptor being used by this object.
* @author Peter Jones
**/
//####################################################################
socket_type get_socketfd (void) const;
//####################################################################
/**
* Get information about how this Stream should be probed from the
* Netxx::Probe class.
*
* @return A Netxx::ProbeInfo object.
* @author Peter Jones
**/
//####################################################################
const ProbeInfo* get_probe_info (void) const;
private:
struct pimpl; pimpl *pimpl_;
}; // end Netxx::Stream class
} // end Netxx namespace
#endif
Netxx-0.3.2/include/Netxx/DatagramServer.h 0000644 0001750 0001750 00000014775 12173720353 017726 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the definition of the Netxx::DatagramServer class.
**/
#ifndef _Netxx_DatagramServer_h_
#define _Netxx_DatagramServer_h_
// Netxx includes
#include
#include
#include
#include
// standard includes
#include
namespace Netxx {
// forward declarations
class ProbeInfo;
class ServerBase;
/**
* The Netxx::DatagramServer class is used for datagram based servers.
**/
class DatagramServer {
public:
/// type returned from receive_datagram
typedef std::pair receive_type;
//####################################################################
/**
* Create a datagram server that will bind to all local addresses on the
* given port number. The timeout will be used when you make a call to
* receive_datagram.
*
* @param port The local port number to bind to.
* @param timeout The timeout to use for server operations.
* @author Peter Jones
**/
//####################################################################
explicit DatagramServer (port_type port, const Timeout &timeout=Timeout());
//####################################################################
/**
* Create a datagram server that will bind to all addresses given in the
* Address class.
*
* @param addr The list of addresses to bind to.
* @param timeout The timeout to use for server operations.
* @author Peter Jones
**/
//####################################################################
explicit DatagramServer (const Address &addr, const Timeout &timeout=Timeout());
//####################################################################
/**
* Clean up after the DatagramServer.
*
* @author Peter Jones
**/
//####################################################################
~DatagramServer (void);
//####################################################################
/**
* Try to receive an incoming datagram. If you have set a timeout and no
* datagram is pending within that timeout this memeber function will
* return with -1 for the bytes read and an invalid Peer class. If no
* timeout was given, this function will block until a datagram arives.
* Once a datagram has been received it will be stored inside the given
* buffer and the amount of stored data along with data about the sender
* of the datagram will returned in a std::pair.
*
* @param buffer The buffer where the datagram data can be placed.
* @param length The size of the buffer.
* @return A std::pair where first is the bytes placed in the buffer and
* second is the Peer class for the sending peer.
* @author Peter Jones
**/
//####################################################################
receive_type receive (void *buffer, size_type length);
//####################################################################
/**
* Send a datagram to the given peer. The send will occur using the
* datagram server socket. This may not be thread safe. Some protocols
* will send a datagram to the client using the server socket with
* information about another port to start talking on. It is up to the
* developer to decide which approach is better, to respond using the
* server datagram socket or create a new datagram server or client for
* the communication.
*
* Using the same DatagramServer object in multiple threads of execution
* and then calling the send() member function will probably cause you
* problems and a debugging nightmare.
*
* @param peer The peer to send the datagram to.
* @param buffer The buffer that contains the datagram to send.
* @param length The size of the datagram to send.
* @return The number of bytes sent or -1 in the case of a timeout.
**/
//####################################################################
signed_size_type send (const Peer &peer, const void *buffer, size_type length);
//####################################################################
/**
* Get information about how this DatagramServer should be probed from
* the Netxx::Probe class.
*
* @return A Netxx::ProbeInfo object.
* @author Peter Jones
**/
//####################################################################
const ProbeInfo* get_probe_info (void) const;
friend bool operator== (const DatagramServer &ds, socket_type fd);
friend bool operator== (socket_type fd, const DatagramServer &ds);
friend bool operator!= (const DatagramServer &ds, socket_type fd);
friend bool operator!= (socket_type fd, const DatagramServer &ds);
private:
ServerBase *pimpl_;
DatagramServer (const DatagramServer&);
DatagramServer& operator= (const DatagramServer&);
}; // end Netxx::DatagramServer class
} // end Netxx namespace
#endif
Netxx-0.3.2/include/Netxx/Netbuf.h 0000644 0001750 0001750 00000016015 12173720353 016227 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/** @file
* This file contains the definition of the Netxx:Netbuf template class.
**/
#ifndef _Netxx_Netbuf_h_
#define _Netxx_Netbuf_h_
// Netxx includes
#include
// standard includes
#include
#include
#include
namespace Netxx {
const std::streamsize PUTBACK_SIZE = 4;
}
namespace Netxx {
/**
* The Netxx::Netbuf template class is a IOStreams streambuf. After you
* create an instance of a Netxx::Netbuf class you can pass a pointer to it
* to a std::iostream, std::ostream or std::istream class. Then you can do
* basic IOStreams operations on it.
*
* This streambuf is buffered so you should call std::flush to make sure it
* sends the data that you inserted.
**/
template >
class Netbuf : public std::basic_streambuf {
public:
/// int type
typedef typename std::basic_streambuf::int_type int_type;
/// char type
typedef typename std::basic_streambuf::char_type char_type;
//####################################################################
/**
* Construct a Netxx::Netbuf object and link it to the given StreamBase
* object. The StreamBase object will be used for reading and writing to
* the Netbuf (std::streambuf) object.
*
* @param stream The StreamBase object to use for reading and writing.
* @author Peter Jones
**/
//####################################################################
explicit Netbuf (StreamBase &stream);
//####################################################################
/**
* Netxx::Netbuf class destructor.
*
* @author Peter Jones
**/
//####################################################################
~Netbuf (void);
protected:
// TODO streamsize xsputn (const char_type *s, streamsize n);
int_type overflow (int_type c=traits::eof());
int sync (void);
int_type underflow (void);
int_type pbackfail (int_type c);
private:
StreamBase &stream_;
charT putbuf_[bufsize];
charT getbuf_[bufsize];
int buffer_out (void);
int buffer_in (void);
Netbuf (const Netbuf&);
Netbuf& operator= (const Netbuf&);
}; // end Netxx::Netbuf class
//#############################################################################
template
Netbuf::Netbuf (StreamBase &stream)
: stream_(stream)
{
setp(putbuf_, putbuf_ + bufsize);
setg(getbuf_+PUTBACK_SIZE, getbuf_+PUTBACK_SIZE, getbuf_+PUTBACK_SIZE);
}
//#############################################################################
template
Netbuf::~Netbuf (void) {
sync();
}
//#############################################################################
template
typename Netbuf::int_type Netbuf::overflow (int_type c) {
if (buffer_out() < 0) {
return traits::eof();
} else if (!traits::eq_int_type(c, traits::eof())) {
return sputc(c);
} else {
return traits::not_eof(c);
}
}
//#############################################################################
template
int Netbuf::sync (void) {
return buffer_out();
}
//#############################################################################
template
int Netbuf::buffer_out (void) {
int length = this->pptr() - this->pbase();
int rc = stream_.write(putbuf_, length);
this->pbump(-length);
return rc;
}
//#############################################################################
template
typename Netbuf::int_type Netbuf::underflow (void) {
if (this->gptr() < this->egptr())
return traits::to_int_type(*this->gptr());
if (buffer_in() < 0) return traits::eof();
else return traits::to_int_type(*this->gptr());
}
//#############################################################################
template
typename Netbuf::int_type Netbuf::pbackfail(int_type c) {
if (this->gptr() != this->eback()) {
this->gbump(-1);
if (!traits::eq_int_type(c, traits::eof())) {
*(this->gptr()) = traits::to_char_type(c);
}
return traits::not_eof(c);
} else {
return traits::eof();
}
}
//#############################################################################
template
int Netbuf::buffer_in (void) {
std::streamsize number_putbacks = std::min(this->gptr() - this->eback(), PUTBACK_SIZE);
std::memcpy(getbuf_ + (PUTBACK_SIZE - number_putbacks) * sizeof(char_type),
this->gptr() - number_putbacks * sizeof(char_type), number_putbacks * sizeof(char_type));
int rc = stream_.read(getbuf_ + PUTBACK_SIZE * sizeof(char_type), bufsize - PUTBACK_SIZE);
if (rc <= 0) {
this->setg(0, 0, 0);
return -1;
} else {
this->setg(getbuf_ + PUTBACK_SIZE - number_putbacks, getbuf_ + PUTBACK_SIZE, getbuf_ + PUTBACK_SIZE + rc);
return rc;
}
}
} // end Netxx namespace
#endif
Netxx-0.3.2/examples/ 0000755 0001750 0001750 00000000000 12173720372 013716 5 ustar daniel daniel Netxx-0.3.2/examples/.cvsignore 0000644 0001750 0001750 00000000233 12173720353 015713 0 ustar daniel daniel Makefile
http_get
multi_server
streambuf_echo_client
tcp_daytime_client
tcp_echo_client
tcp_echo_server
udp_daytime_client
udp_echo_client
udp_echo_server
Netxx-0.3.2/examples/tls_echo_server.cxx 0000644 0001750 0001750 00000006200 12173720353 017625 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Similar to the tcp_echo_server.cxx example, this example shows you how to
* write a TLS server. It will echo back everything that a TLS echo client
* sends it.
*/
// Netxx Includes
#include
#include
#include
#include
#include
#include
#include
// Standard Includes
#include
#include
int main (int argc, char *argv[]) {
try {
Netxx::Address address;
Netxx::Timeout timeout(60);
Netxx::TLS::Context context;
context.load_private_key("example.pem");
context.load_cert_chain("example.pem");
if (argc > 1) {
for (int i=1; i 0)
client_stream.write(buffer, bytes_read);
std::cout << argv[0] << ": client disconnected from server" << std::endl;
}
} catch (std::exception &e) {
std::cerr << argv[0] << ": " << e.what() << std::endl;
return 1;
}
return 0;
}
Netxx-0.3.2/examples/http_get.cxx 0000644 0001750 0001750 00000005666 12173720353 016274 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This is a simple example of how you can use the Netxx::Address class and
* the Netxx::Stream class to do make a HTTP GET request to a web server.
*/
// Netxx Includes
#include
#include
#include
#include
// Standard Includes
#include
#include
int main (int argc, char *argv[]) {
if (argc != 2 && argc != 3) {
std::cout << "Usage: " << argv[0] << " URI [Host: header]\n";
return 0;
}
try {
Netxx::Address addr(argv[1], 80);
Netxx::Stream client(addr, Netxx::Timeout(10));
std::string request("GET ");
if (addr.get_path()) {
request += addr.get_path();
} else {
request += "/";
}
// setup the request line and headers
request += " HTTP/1.0";
request += 13; request += 10;
// send the Host header
request += "Host: ";
if (argc == 3) request += argv[2];
else request += addr.get_name();
request += 13; request += 10;
request += "Connection: close";
request += 13; request += 10;
request += 13; request += 10;
// send the request
client.write(request.c_str(), request.size());
char buffer[1024];
Netxx::signed_size_type length;
// read back the result
while ( (length = client.read(buffer, sizeof(buffer))) > 0)
std::cout.write(buffer, length);
} catch (std::exception &e) {
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
}
Netxx-0.3.2/examples/README 0000644 0001750 0001750 00000000461 12173720353 014576 0 ustar daniel daniel Netxx Examples
Any of the examples in this directory that take address options can use the
URL syntax for an address. For example, to run the tcp_echo_server on port
7000:
./tcp_echo_server localhost:7000
Or, to make it use a local domain socket:
./tcp_echo_server /tmp/echo.socket
Have fun!
Netxx-0.3.2/examples/udp_echo_client.cxx 0000644 0001750 0001750 00000005666 12173720353 017602 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This example shows you how to use the UDP API. It will read a line from
* standard input and send a datagram to a server. The UDP echo server will
* then send back the same data in another datagram. This example uses
* "connected" UDP sockets.
*/
// Netxx Includes
#include
#include
#include
// Standard Includes
#include
#include
#include
int main (int argc, char *argv[]) {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " \n";
return 1;
}
try {
Netxx::Datagram datagram(argv[1], 7, Netxx::Timeout(5));
Netxx::signed_size_type bytes_received;
char read_buffer[4096];
std::string write_buffer;
while (std::getline(std::cin, write_buffer)) {
if (write_buffer.size() > sizeof(read_buffer)) {
std::cerr << argv[0] << ": can't send a line longer than ";
std::cerr << sizeof(read_buffer) << " bytes\n";
return 1;
}
write_buffer += '\n';
datagram.write(write_buffer.c_str(), write_buffer.size());
if ( (bytes_received = datagram.read(read_buffer,
sizeof(read_buffer))) > 0)
{
std::cout.write(read_buffer, bytes_received);
}
else
{
std::cerr << argv[0] << ": datagram receive timeout\n";
}
}
} catch (std::exception &e) {
std::cerr << argv[0] << ": " << e.what() << "\n";
return 1;
}
return 0;
}
Netxx-0.3.2/examples/tcp_daytime_client.cxx 0000644 0001750 0001750 00000004475 12173720353 020313 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This example shows you how to use the Netxx::Stream class to establish a
* connection to a daytime server and get the current time. This is a nice
* and short example that shows how easy it can be to use Netxx.
*/
// Netxx Includes
#include
#include
// Standard Includes
#include
#include
int main (int argc, char *argv[]) {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " \n";
return 1;
}
try {
Netxx::Stream client(argv[1], 13, Netxx::Timeout(2));
char buffer[1024];
buffer[ client.read(buffer, sizeof(buffer) - 1) ] = 0;
std::cout << buffer;
} catch (std::exception &e) {
std::cerr << argv[0] << ": " << e.what() << std::endl;
return 1;
}
return 0;
}
Netxx-0.3.2/examples/http_https_server.cxx 0000644 0001750 0001750 00000012767 12173720353 020245 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This is a very simple web server using a lot of different classes from
* Netxx. It will accept incoming HTTP and HTTPS requests. This example is a
* little big, but is does do some basic HTTP/1.0 web server stuff!
*
* Remember, this is just an example! This web server does not have any
* security checking. In fact, using some ../../ directory references,
* someone could get your password file!
*/
// Netxx includes
#include
#include
#include
#include
#include
#include
#include
#include
// standard includes
#include
#include
#include
#include
int main (int argc, char *argv[]) {
std::string document_root;
if (argc < 2) document_root = "../src";
else document_root = argv[1];
if (document_root[document_root.size()-1] != '/')
document_root += '/';
try {
Netxx::TLS::Context context;
context.load_private_key("example.pem");
context.load_cert_chain("example.pem");
// bind to all addresses for the following ports
Netxx::Address address;
address.add_all_addresses(8080);
address.add_all_addresses(8443);
Netxx::Timeout accept_timeout(600);
Netxx::Timeout read_timeout(60);
Netxx::StreamServer server(address, accept_timeout);
std::cout << "waiting for HTTP requests on port 8080\n";
std::cout << "waiting for HTTPS requests on port 8443\n";
for (;;) {
Netxx::Peer client = server.accept_connection();
if (!client) {
std::cout << argv[0] << ": timeout waiting for connection";
std::cout << std::endl;
continue;
}
std::cout << argv[0] << ": connection from " << client;
std::cout << std::endl;
std::auto_ptr client_stream;
if (client.get_local_port() == 8080) {
client_stream.reset(new Netxx::Stream(
client.get_socketfd(), read_timeout));
} else {
client_stream.reset(new Netxx::TLS::Stream(
context, client.get_socketfd(),
Netxx::TLS::Stream::mode_server, read_timeout));
}
Netxx::Netbuf<1024> sbuf(*client_stream);
std::iostream stream(&sbuf);
std::string token;
stream >> token;
if (token != "GET") continue;
stream >> token;
std::cout << argv[0] << ": " << token << std::endl;
if (token == "/") {
std::string message = ""
"Hello from Netxx
\n";
stream << "HTTP/1.0 200 OK\r\n";
stream << "Content-Type: text/html\r\n";
stream << "Content-Length: " << message.size() << "\r\n";
stream << "Connection: closed\r\n\r\n";
stream << message << std::flush;
continue;
}
std::string document = document_root + token;
std::ifstream file(document.c_str());
if (!file) {
stream << "HTTP/1.0 404 Not found\r\n";
stream << "Content-Type: text/html\r\n";
stream << "Connection: closed\r\n\r\n";
stream << "Not Found
\n";
stream << std::flush;
continue;
}
stream << "HTTP/1.0 200 OK\r\n";
std::string::size_type dotpos = token.rfind(".");
if (dotpos != std::string::npos) {
std::string ext = token.substr(dotpos+1);
if (ext == "html" || ext == "htm") {
stream << "Content-Type: text/html\r\n";
} else if (ext == "jpeg" || ext == "jpg") {
stream << "Content-Type: image/jpeg\r\n";
} else if (ext == "gif") {
stream << "Content-Type: image/gif\r\n";
} else if (ext == "png") {
stream << "Content-Type: image/png\r\n";
} else {
stream << "Content-Type: text/plain\r\n";
}
} else {
stream << "Content-Type: text/plain\r\n";
}
stream << "Connection: closed\r\n\r\n";
stream << std::flush;
char buffer[4096];
while (file.read(buffer, sizeof(buffer)) || file.gcount())
stream.write(buffer, file.gcount());
}
} catch (std::exception &e) {
std::cerr << argv[0] << ": " << e.what() << std::endl;
return 1;
}
return 0;
}
Netxx-0.3.2/examples/udp_daytime_client.cxx 0000644 0001750 0001750 00000005164 12173720353 020311 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This example shows you how to use the UDP API. It sends a blank datagram
* to a daytime server. The daytime server should then send back a datagram
* with the current date and time.
*/
// Netxx Includes
#include
#include
#include
#include
// Standard Includes
#include
#include
#include
int main (int argc, char *argv[]) {
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " address\n";
return 1;
}
try {
Netxx::Address addr(argv[1], 13);
Netxx::Datagram datagram(Netxx::Timeout(10));
char buffer[1024];
// send blank datagram to make server respond
datagram.send(*addr.begin(), 0, 0);
Netxx::Datagram::receive_type response =
datagram.receive(buffer, sizeof(buffer));
if (response.first == -1) {
std::cerr << argv[0] << ": timeout waiting for server\n";
return 1;
}
std::cout.write(buffer, response.first);
} catch (std::exception &e) {
std::cerr << argv[0] << ": " << e.what() << "\n";
return 1;
}
return 0;
}
Netxx-0.3.2/examples/streambuf_echo_client.cxx 0000644 0001750 0001750 00000005117 12173720353 020771 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This example shows you how you can use the Netxx::Netbuf template class
* as a IOStreams streambuf. Doing so allows you to treat a TCP connection
* as an IOStream.
*/
// Netxx Includes
#include
#include
#include
// Standard Includes
#include
#include
#include
int main (int argc, char *argv[]) {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " \n";
return 1;
}
try {
Netxx::Stream client(argv[1], 7, Netxx::Timeout(2));
Netxx::Netbuf<1024> sbuf(client);
std::iostream stream(&sbuf);
std::string string_buffer;
while (std::getline(std::cin, string_buffer)) {
stream << string_buffer << std::endl;
if (std::getline(stream, string_buffer)) {
std::cout << string_buffer << std::endl;
} else {
std::cerr << argv[0] << " error reading from server";
std::cerr << std::endl;
return 1;
}
}
} catch (std::exception &e) {
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
}
Netxx-0.3.2/examples/multi_server.cxx 0000644 0001750 0001750 00000014314 12173720353 017164 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This example shows you how to use the Netxx::Probe class. In this case,
* we have a group of server classes and we use the Probe to know when we
* can accept a connection on one of the servers.
*/
// Netxx Includes
#include
#include
#include
#include
#include
#include
// Standard Includes
#include
#include
#include
namespace {
const Netxx::port_type const_port_echo = 4000;
const Netxx::port_type const_port_daytime = 4001;
const Netxx::size_type const_buffer_size = 4096;
}
int main (int argc, char *argv[]) {
if (argc > 1) {
std::cerr << argv[0] << ": this program does not take any options\n";
return 1;
}
try {
Netxx::Timeout timeout(5);
Netxx::Probe probe;
Netxx::StreamServer tcp_echo_server(const_port_echo, timeout);
Netxx::DatagramServer udp_echo_server(const_port_echo, timeout);
Netxx::StreamServer tcp_daytime_server(const_port_daytime, timeout);
Netxx::DatagramServer udp_daytime_server(const_port_daytime, timeout);
std::cout << argv[0] << ": tcp echo server listening on port ";
std::cout << const_port_echo << std::endl;
std::cout << argv[0] << ": udp echo server listening on port ";
std::cout << const_port_echo << std::endl;
std::cout << argv[0] << ": tcp daytime server listening on port ";
std::cout << const_port_daytime << std::endl;
std::cout << argv[0] << ": udp daytime server listening on port ";
std::cout << const_port_daytime << std::endl;
/*
* add servers to the Probe for readable testing since we only care
* when the sockets are readable not writable.
*/
probe.add(tcp_echo_server, Netxx::Probe::ready_read);
probe.add(udp_echo_server, Netxx::Probe::ready_read);
probe.add(tcp_daytime_server, Netxx::Probe::ready_read);
probe.add(udp_daytime_server, Netxx::Probe::ready_read);
char buffer[const_buffer_size];
Netxx::Probe::result_type rt;
for (;;) {
rt = probe.ready(timeout);
if (rt.first == -1 || !(rt.second & Netxx::Probe::ready_read)) {
std::cout << argv[0] << ": timeout waiting for connection" << std::endl;
continue;
}
std::cout << argv[0] << ": one of the servers is ready, testing ..." << std::endl;
if (rt.first == tcp_echo_server)
{
Netxx::Peer peer = tcp_echo_server.accept_connection();
if (!peer) {
std::cout << argv[0] << ": timeout in accept" << std::endl;
continue;
}
std::cout << argv[0] << ": incoming TCP-ECHO connection from: " << peer << std::endl;
Netxx::Stream client(peer.get_socketfd(), timeout);
Netxx::signed_size_type bytes_read;
while ( (bytes_read = client.read(buffer, sizeof(buffer))) > 0)
client.write(buffer, bytes_read);
std::cout << argv[0] << ": connection with " << peer << " closed" << std::endl;
}
else if (rt.first == udp_echo_server)
{
Netxx::DatagramServer::receive_type info =
udp_echo_server.receive(buffer, sizeof(buffer));
if (!info.second) {
std::cout << argv[0] << ": timeout waiting for datagram";
std::cout << std::endl;
continue;
}
std::cout << argv[0] << ": incoming UDP-ECHO datagram from ";
std::cout << info.second << std::endl;
udp_echo_server.send(info.second, buffer, info.first);
std::cout << argv[0] << ": sent datagram to " << info.second << std::endl;
}
else if (rt.first == tcp_daytime_server)
{
Netxx::Peer peer = tcp_daytime_server.accept_connection();
if (!peer) {
std::cout << argv[0] << ": timeout in accept" << std::endl;
continue;
}
std::cout << argv[0] << ": incoming TCP-DAYTIME connection from: " << peer << std::endl;
Netxx::Stream client(peer.get_socketfd(), timeout);
std::time_t now = std::time(0);
char *time_str = std::ctime(&now);
client.write(time_str, std::strlen(time_str));
std::cout << argv[0] << ": connection with " << peer << " closed" << std::endl;
}
else if (rt.first == udp_daytime_server)
{
Netxx::DatagramServer::receive_type info =
udp_daytime_server.receive(buffer, sizeof(buffer));
if (!info.second) {
std::cout << argv[0] << ": timeout waiting for datagram";
std::cout << std::endl;
continue;
}
std::cout << argv[0] << ": incoming UDP-DAYTIME datagram from ";
std::cout << info.second << std::endl;
std::time_t now = std::time(0);
char *time_str = std::ctime(&now);
udp_daytime_server.send(info.second, time_str, std::strlen(time_str));
std::cout << argv[0] << ": sent datagram to " << info.second << std::endl;
}
}
} catch (std::exception &e) {
std::cerr << argv[0] << ": " << e.what() << std::endl;
return 1;
}
return 0;
}
Netxx-0.3.2/examples/https_get.cxx 0000644 0001750 0001750 00000007363 12173720353 016453 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This example shows you how to make a TLS request and examin the the
* server's certificate.
*/
// Netxx Includes
#include
#include
#include
#include
// Standard Includes
#include
#include
int main (int argc, char *argv[]) {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " URI\n";
return 0;
}
try {
Netxx::TLS::Context context;
Netxx::Address addr(argv[1], 443);
Netxx::TLS::Stream client(context, addr, Netxx::Timeout(10));
const Netxx::TLS::Certificate &peer_cert = client.get_peer_cert();
const Netxx::TLS::Certificate &issuer_cert = client.get_issuer_cert();
if (peer_cert) {
std::cout << "Peer Certificate:\n";
std::cout << " C: " << peer_cert.get_country() << "\n";
std::cout << " ST: " << peer_cert.get_region() << "\n";
std::cout << " O: " << peer_cert.get_organization() << "\n";
std::cout << " OU: " << peer_cert.get_organization_unit() << "\n";
std::cout << " CN: " << peer_cert.get_fqdn() << "\n\n";
} else {
std::cout << "Missing Peer Certificate\n\n";
}
if (issuer_cert) {
std::cout << "Issuer Certificate:\n";
std::cout << " C: " << issuer_cert.get_country() << "\n";
std::cout << " ST: " << issuer_cert.get_region() << "\n";
std::cout << " O: " << issuer_cert.get_organization() << "\n";
std::cout << " OU: " << issuer_cert.get_organization_unit() << "\n";
std::cout << " CN: " << issuer_cert.get_fqdn() << "\n\n";
} else {
std::cout << "Missing Issuer Certificate\n\n";
}
std::string request("GET ");
if (addr.get_path()) {
request += addr.get_path();
} else {
request += "/";
}
request += " HTTP/1.0\r\n";
request += "Host: ";
request += addr.get_name();
request += "\r\n";
request += "Connection: close\r\n\r\n";
client.write(request.c_str(), request.size());
char buffer[1024];
Netxx::signed_size_type length;
while ( (length = client.read(buffer, sizeof(buffer))) > 0)
std::cout.write(buffer, length);
} catch (std::exception &e) {
std::cerr << argv[0] << ": " << e.what() << std::endl;
return 1;
}
return 0;
}
Netxx-0.3.2/examples/tls_echo_client.cxx 0000644 0001750 0001750 00000005514 12173720353 017604 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Like the tcp_echo_client.cxx example, this one shows you how to write a
* TCP echo client. The difference is that this one will use the TLS API so
* that you can talk with a secure echo server!
*/
// Netxx Includes
#include
#include
#include
#include
// Standard Includes
#include
#include
#include
int main (int argc, char *argv[]) {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " \n";
return 1;
}
try {
Netxx::TLS::Context context;
Netxx::TLS::Stream client(context, argv[1], 7, Netxx::Timeout(10));
Netxx::signed_size_type bytes_read;
char read_buffer[4096];
std::string write_buffer;
while (std::getline(std::cin, write_buffer)) {
if (write_buffer.size() > sizeof(read_buffer)) {
std::cerr << "can't send a line longer than ";
std::cerr << sizeof(read_buffer) << " bytes\n";
return 1;
}
write_buffer += '\n';
client.write(write_buffer.c_str(), write_buffer.size());
bytes_read = client.read(read_buffer, sizeof(read_buffer));
std::cout.write(read_buffer, bytes_read);
}
} catch (std::exception &e) {
std::cerr << argv[0] << ": " << e.what() << std::endl;
return 1;
}
return 0;
}
Netxx-0.3.2/examples/Makefile 0000644 0001750 0001750 00000003522 12173720353 015357 0 ustar daniel daniel # This Makefile automaticly generated by /home/jason/head/contrib/Netxx-0.3.2/tools/mkmf
# File created on: Fri Apr 15 12:01:20 2005
# DO NOT EDIT THIS FILE!
CXX=c++
CXXFLAGS=-O2 -I/home/jason/head/contrib/Netxx-0.3.2/include
AR=ar
ARFLAGS=rc
SAR=c++
SARFLAGS=
LD=c++
LDFLAGS='/home/jason/head/contrib/Netxx-0.3.2/src/libNetxx.a'
POST_LDFLAGS=
OBJECTS=http_get.o multi_server.o streambuf_echo_client.o tcp_daytime_client.o tcp_echo_client.o tcp_echo_server.o udp_daytime_client.o udp_echo_client.o udp_echo_server.o
TARGETS=http_get multi_server streambuf_echo_client tcp_daytime_client tcp_echo_client tcp_echo_server udp_daytime_client udp_echo_client udp_echo_server
all: $(TARGETS)
http_get: http_get.o
$(LD) -o http_get http_get.o $(LDFLAGS) $(POST_LDFLAGS)
multi_server: multi_server.o
$(LD) -o multi_server multi_server.o $(LDFLAGS) $(POST_LDFLAGS)
streambuf_echo_client: streambuf_echo_client.o
$(LD) -o streambuf_echo_client streambuf_echo_client.o $(LDFLAGS) $(POST_LDFLAGS)
tcp_daytime_client: tcp_daytime_client.o
$(LD) -o tcp_daytime_client tcp_daytime_client.o $(LDFLAGS) $(POST_LDFLAGS)
tcp_echo_client: tcp_echo_client.o
$(LD) -o tcp_echo_client tcp_echo_client.o $(LDFLAGS) $(POST_LDFLAGS)
tcp_echo_server: tcp_echo_server.o
$(LD) -o tcp_echo_server tcp_echo_server.o $(LDFLAGS) $(POST_LDFLAGS)
udp_daytime_client: udp_daytime_client.o
$(LD) -o udp_daytime_client udp_daytime_client.o $(LDFLAGS) $(POST_LDFLAGS)
udp_echo_client: udp_echo_client.o
$(LD) -o udp_echo_client udp_echo_client.o $(LDFLAGS) $(POST_LDFLAGS)
udp_echo_server: udp_echo_server.o
$(LD) -o udp_echo_server udp_echo_server.o $(LDFLAGS) $(POST_LDFLAGS)
clean:
- rm -f $(OBJECTS) $(TARGETS) *.core core
realclean: clean
- rm -f Makefile
.SUFFIXES: .cxx
.SUFFIXES: .obj
.cxx.o:
$(CXX) $(CXXFLAGS) -c $<
.cxx.obj:
$(CXX) $(CXXFLAGS) -c $<
Netxx-0.3.2/examples/udp_echo_server.cxx 0000644 0001750 0001750 00000005216 12173720353 017621 0 ustar daniel daniel /*
* Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This example shows you how to write a UDP server. It will send back any
* datagrams that it receives.
*/
// Netxx Includes
#include
#include
#include
#include
// Standard Includes
#include
#include
int main (int argc, char *argv[]) {
try {
Netxx::Address addr;
if (argc > 1) {
for (int i=1; i