AUTHOR
Sasha Pachev <sasha@sashanet.com>
ABOUT
libtcp++ is a free C++ class library to facilitate writing TCP/IP client-server
applications written and maintained by Sasha Pachev <sasha@sashanet.com>
REQUIREMENTS
a C++ compiler on a Unix platform with STL support to the exent of GCC 2.7,
a reasonably recent version GCC itself is the best compiler to compile it on.
The library will cleanly compile on Linux and BSD with g++. Other configurations
have not yet been tested. You may need to change a few lines to make it work on
another platform/compiler. Please let me know what you did to make it work in
that case.
VERSION
0.1.0
INSTALL
gunzip -c libtcp++*.tar.gz | tar xvf -
cd libtcp++-*
./configure
make
su
make install
USAGE
#include <tcp++/tcp_client.h>
#include <tcp++/tcp_server.h>
to link use -ltcp++
The use of the client should be pretty obvious from the header file and the test example in
tcp_client.cc
The same applies to the server (see tcp_server.cc ), but one thing requires explanation:
to write your own server, inherit from TcpServer and implement handle_client(int sock_fd)
the server will listen on the port specified in the constructor and fork when connection
is made calling your implementation of handle_client() see source for more details
To use IP access control, after instantiating TcpServer call add_ip_rule(netnum,
netmask) of each rule. Use netmask of 255.255.255.255 for a single host, and
its IP for netnum. Both netnum and netmask are C string representations of
IP addresses/masks, not the 4-byte arrays. They will be parsed by inet_aton().
After setting up all the rules with add_ip_rule(), activate them with
enable_access_control(). After you have called enable_access_control() all
connections will be denied except those coming from host that match one of
the rules you have added. You can disable it with disable_access_control()
HISTORY
0.0.1 - Mar 10, 1999
first release
0.0.1a - Mar 11, 1999
fixed the log messages flushing problem
0.0.1b - Mar 16, 1999
fixed the block on wait3() when some client handler child had exited and others had not
by fixing the loop in reaper() in tcp_server.h
0.0.1c - Mar 23, 1999 - added debug() method to TCP Server
0.0.2 - added IP-based access control capability to the TcpServer through a new
class TcpIpRuleSet, which could be used independently of TcpServer to
validate an IP address against a set of rules.
0.0.4 - Oct 24, 1999 added connect timeout for TcpClient, TcpClient::receive() has a
now configurable a timeout (0 sec 0 usec means no timeout), renamed .c files to
.cc, added setsockopt with SO_REUSEADDR on the server socket, added socklen_t to
make it compile on RedHat 6.0 and some others without warnings where this is the
type of the last argument to accept().
0.0.5 - Nov 10, 1999 - added init() methods and no-arguments constructor to TcpClient,
now you can initialize a TcpClient by just supplying the host's struct in_addr and the
port to connect on -- details in the tcp_client.h .
0.1.0 - Nov 15, 1999 -- finally converted to autoconf/automake
0.1.1 - Jan 23, 2000 -- fixed a bug in configure that made the compilation
bomb on Red Hat 6.1
BUGS
report them to Sasha Pachev <sasha@sashanet.com>
TO DO
- Test, test, test
- documentation
LICENSE
You may use and modify the code as long as proper credit is given.
As with all freeware, I assume no legal responsibility for any damage that may result from
the use of libtcp++
|