Skip to content
DataReel Software Development
  1. Home
  2. C++ API
  3. Examples
  4. Example Programs in This Distribution
Examples

Example Programs in This Distribution

Contents

Building and Running
Database Examples
General Examples
Socket Examples
Thread Examples

Building and Running

Each example program is in its own folder under examples_database, examples_general, examples_socket and examples_threads. The programs test one part of the library each and can be used as templates for new applications. The listings in the menu on the left are older programs kept for reference; the programs below are the ones built and tested with this release.

To build and run an example on Linux:

cd datareel/env
source gnu_env.sh
cd ../examples_database/simple
make
./testprog

On Windows use nmake -f msvc.mak in the same folder. The SSL examples (https_client, ssl_server and ssl_verify_cert) need the library built with OpenSSL; see Linux Builds. Most test programs pause between steps and wait for Enter. string_class can be built with -D__AUTORUN_TESTPROG__ to run without prompts. All of these programs were run under AddressSanitizer and UndefinedBehaviorSanitizer for the 10/14/2026 code review.

Database Examples

Folder: examples_database

ProgramSource filesWhat it showsClass
btreetestprog.cppInsert, find and delete keys with the gxBtree class.gxbtree
btree_cachedtestprog.cppThe same B-tree operations through the B-tree cache.btcache
btree_nodetestprog.cppTests the B-tree node class.btnode
databasetestprog.cppCompares the 32-bit and 64-bit database engines.gxdbase
database_cachetestprog.cppTests the database file cache classes.dbfcache
defragtestprog.cppReclaims deleted blocks with gxDatabase::Reclaim() using the first-fit or best-fit method.gxdbase
podtestprog.cppTests the Persistent Object Database (POD) manager.pod
simpletestprog.cppA simple demo of the gxDatabase class.gxdbase

General Examples

Folder: examples_general

ProgramSource filesWhat it showsClass
binary_search_treetestprog.cppTests the generic binary search tree class. Interactive menu; enter q to quit.gxbstree
config_classtestprog.cppReads and changes values in a text configuration file with gxConfig.gxconfig
device_cachetestprog.cppTests the device cache classes.devcache
disk_file_classtestprog.cppTests the DiskFileB file I/O class.dfileb
doubly_linked_listtestprog.cppTests the doubly linked list class. Shows how to free strings allocated with new[].gxlist
file_utilstestprog.cppTests the file and directory utility functions. Run with a directory name: testprog /tmpfutils
html_parsertestprog.cppTests the gxsHTML parser classes.gxshtml
logfiletestprog.cppTests the LogFile class.logfile
memory_buffertestprog.cppTests the MemoryBuffer class.membuf
string_classtestprog.cppTests the gxString (UString) class, including Unicode strings.gxstring
url_parsertestprog.cppTests the gxsURL parser classes.gxsurl
xml_parsertestprog.cppLoads an XML file into an in-memory tree (DOM parsing) and writes it back out. Run with a file name, or -t to write a test file: testprog testfile.xmlgxsxml

Socket Examples

Folder: examples_socket

ProgramSource filesWhat it showsClass
broadcastclient.cpp, server.cppUDP broadcast client and server.gxsocket
echo_serverclient.cpp, server.cppTCP echo client and server.gxsocket
ftp_clienttestprog.cppTests the embedded FTP client class.gxsftp
hostinfotestprog.cppGets host name information.gxsutils
http_clienttestprog.cppTests the HTTP, HTML and URL classes.gxshttpc
http_serverhttpserv.cpp, httpserv.h, server.cppMulti-threaded HTTP server framework built on gxSocket and gxThread.gxshttp
https_clienttestprog.cppHTTPS client using the gxSSL class. Requires an SSL build.gxssl
multi_threaded_serverclient.cpp, m_thread.cpp, m_thread.h, server.cppClient and multi-threaded server using gxSocket and a thread pool.thrpool
multicastclient.cpp, server.cppUDP client and server that join an IP multicast group and exchange datagrams.gxsocket
pingtestprog.cppTests the embedded ping class.gxsping
pop3_clienttestprog.cppTests the embedded POP3 client class.gxspop3
simpleclient.cpp, server.cppSimple TCP stream client and server.gxsocket
smtp_clienttestprog.cppTests the embedded SMTP client class.gxsmtp
socket_cacheclient.cpp, gxsfile.cpp, gxsfile.h, server.cppDevice cache client and server that move cached data over a socket.devcache
ssl_serverm_thread.cpp, m_thread.h, server.cppMulti-threaded HTTPS server using gxSSL. Includes a sample key, certificate and 2048-bit DH parameters. Requires an SSL build.gxssl
ssl_verify_certtestprog.cppClient side SSL certificate verification. Requires an SSL build.gxssl
tcp_send_filetcp_send_file.cppSends a file over a TCP stream socket.gxsocket
telnet_clienttestprog.cppTests the embedded telnet client class.gxtelnet

Thread Examples

Folder: examples_threads

ProgramSource filesWhat it showsClass
canceltestprog.cppCancels a long-running thread.gxthread
conditiontestprog.cppSynchronizes threads with condition variables.gxcond
deadlock1testprog.cppA deadlock that gxMutex recovers from automatically.gxmutex
deadlock2testprog.cppA deadlock that the application recovers from.gxmutex
deadlock_posix_testingtestprog.cppPOSIX robust mutex deadlock detection test for Linux.thelpers
destroytestprog.cppDestroys a thread.gxthread
detachtestprog.cppCreates a detached thread.gxthread
exitingtestprog.cppExits from a thread.gxthread
joinedtestprog.cppJoins a thread.gxthread
messagetestprog.cppThread status and error message functions.gxthread
mutextestprog.cppProtects shared data with gxMutex.gxmutex
prioritytestprog.cppSets thread priorities in a thread pool.thrpool
simpletestprog.cppBasic gxThread use with entry and exit functions.gxthread
specifictestprog.cppCreates thread-specific data.gthreadt
stacktestprog.cppChanges a thread's stack size.gxthread
suspendtestprog.cppSuspends and resumes a thread.gxthread
templatetestprog.cppUses gxThread with templates.gxthread
thread_pooltestprog.cppBasic operation of the thread pool.thrpool
timedtestprog.cppSynchronizes threads with timing delays.gxthread

ExamplesC++ API home