📄 readme
字号:
AUTHORSasha Pachev <sasha@direct1.com>ABOUT libtcp++ is a free C++ class library to facilitate writing TCP/IP client-server applications written and maintained by Sasha Pachev <sasha@direct1.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.0.4 INSTALL gunzip -c libtcp++*.tar.gz | tar xvf -Edit the Makefile to make sure you like it. If your compiler already defines socklen_t, get rid of -DDEFILE_SOCKLEN_T make libtcp++.a su make installUSAGE #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.c The same applies to the server (see tcp_server.c ), 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().BUGS report them to Sasha Pachev <sasha@freeservers.com>TO DO - Test, test, test - documentationLICENSE You may use and modify the code as long as proper credit is given. If you have a website, a link to your favorite page at http://www.sashanet.com/ will be appreciated . I may even link back if I like your site. As with all freeware, I assume no legal responsibility for any damage that may result from the use of libtcp++
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -