Example Programs in This Distribution
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 a library built with SSL: OpenSSL on Linux; on Windows the default native Schannel build (USESSL=0) or an OpenSSL 3.5.x LTS build (USESSL=1); 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
| Program | Source files | What it shows | Class |
| btree | testprog.cpp | Insert, find and delete keys with the gxBtree class. | gxbtree |
| btree_cached | testprog.cpp | The same B-tree operations through the B-tree cache. | btcache |
| btree_node | testprog.cpp | Tests the B-tree node class. | btnode |
| database | testprog.cpp | Compares the 32-bit and 64-bit database engines. | gxdbase |
| database_cache | testprog.cpp | Tests the database file cache classes. | dbfcache |
| defrag | testprog.cpp | Reclaims deleted blocks with gxDatabase::Reclaim() using the first-fit or best-fit method. | gxdbase |
| pod | testprog.cpp | Tests the Persistent Object Database (POD) manager. | pod |
| simple | testprog.cpp | A simple demo of the gxDatabase class. | gxdbase |
| replication_6x | repl6_writer.cpp, repl6_check.cpp, repl6_records.h, run_repl6_cross.sh, run_repl6_xver.sh | 6.4: 6.x programs replicating their records with the DataReel 7.x gxObjRepl (gxv7ObjRepl): repl6_writer as a primary, repl6_check as a copy, with DataReel 7.4 nodes on either side, Linux and Windows (needs DATAREEL7_FEATURES_DIR); README is the how-to. | replication |
| vector_index | testprog.cpp | 6.4: records in a 6.x database found by vector similarity with the 7.x vector index (needs DATAREEL7_FEATURES_DIR). | dr7features |
General Examples
Folder: examples_general
| Program | Source files | What it shows | Class |
| binary_search_tree | testprog.cpp | Tests the generic binary search tree class. Interactive menu; enter q to quit. | gxbstree |
| config_class | testprog.cpp | Reads and changes values in a text configuration file with gxConfig. | gxconfig |
| device_cache | testprog.cpp | Tests the device cache classes. | devcache |
| disk_file_class | testprog.cpp | Tests the DiskFileB file I/O class. | dfileb |
| doubly_linked_list | testprog.cpp | Tests the doubly linked list class. Shows how to free strings allocated with new[]. | gxlist |
| file_utils | testprog.cpp | Tests the file and directory utility functions. Run with a directory name: testprog /tmp | futils |
| html_parser | testprog.cpp | Tests the gxsHTML parser classes. | gxshtml |
| logfile | testprog.cpp | Tests the LogFile class. | logfile |
| memory_buffer | testprog.cpp | Tests the MemoryBuffer class. | membuf |
| string_class | testprog.cpp | Tests the gxString (UString) class, including Unicode strings. | gxstring |
| url_parser | testprog.cpp | Tests the gxsURL parser classes. | gxsurl |
| xml_parser | testprog.cpp | Loads 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.xml | gxsxml |
Socket Examples
Folder: examples_socket
| Program | Source files | What it shows | Class |
| broadcast | client.cpp, server.cpp | UDP broadcast client and server. | gxsocket |
| echo_server | client.cpp, server.cpp | TCP echo client and server. | gxsocket |
| ftp_client | testprog.cpp | Tests the embedded FTP client class. | gxsftp |
| hostinfo | testprog.cpp | Gets host name information. | gxsutils |
| http_client | testprog.cpp | Tests the HTTP, HTML and URL classes. | gxshttpc |
| http_server | httpserv.cpp, httpserv.h, server.cpp | Multi-threaded HTTP server framework built on gxSocket and gxThread. | gxshttp |
| https_client | testprog.cpp | HTTPS client using the gxSSL class. Requires an SSL build. | gxssl |
| multi_threaded_server | client.cpp, m_thread.cpp, m_thread.h, server.cpp | Client and multi-threaded server using gxSocket and a thread pool. | thrpool |
| multicast | client.cpp, server.cpp | UDP client and server that join an IP multicast group and exchange datagrams. | gxsocket |
| ping | testprog.cpp | Tests the embedded ping class. | gxsping |
| pop3_client | testprog.cpp | Tests the embedded POP3 client class. | gxspop3 |
| imap_client | testprog.cpp | Runs one IMAP command (list, count, search, header, body, message, dates, seen, delete) with the embedded IMAP client class. | gxsimap |
| simple | client.cpp, server.cpp | Simple TCP stream client and server. | gxsocket |
| smtp_client | testprog.cpp | Tests the embedded SMTP client class. | gxsmtp |
| socket_cache | client.cpp, gxsfile.cpp, gxsfile.h, server.cpp | Device cache client and server that move cached data over a stream, datagram or serial connection. 6.3.1: the stream server needs client certificates: server --cert server.pem --key server.key --client-ca ca.pem --allow-fingerprint SHA256 (or --allow-cn NAME), or --open for a server without client authentication; a client shutdown request is obeyed only with --allow-remote-shutdown. The client takes --ca ca.pem, --insecure and --cert client.pem --key client.key. | gxstream |
| ssl_server | m_thread.cpp, m_thread.h, server.cpp | Multi-threaded HTTPS server using gxSSL. With OpenSSL it makes server_private_key.pem, server_cert.pem and dhparms.pem on the first run. A Schannel build (the Windows default) cannot make keys or certificates and needs no DH file: put a key and certificate made with openssl in server_private_key.pem and server_cert.pem (6.3.1). Requires an SSL build. | gxssl |
| ssl_verify_cert | testprog.cpp | Client side SSL certificate verification. Requires an SSL build. | gxssl |
| vector_client | testprog.cpp, run_vector_client.sh | 6.4: VECTOR_SEARCH and VECTOR_INFO on a DataReel 7.x object server over mutual TLS (needs DATAREEL7_FEATURES_DIR). | dr7features |
| tcp_send_file | tcp_send_file.cpp | Sends a file over a TCP stream socket. | gxsocket |
| telnet_client | testprog.cpp | Tests the embedded telnet client class. | gxtelnet |
Thread Examples
Folder: examples_threads
| Program | Source files | What it shows | Class |
| cancel | testprog.cpp | Cancels a long-running thread. | gxthread |
| condition | testprog.cpp | Synchronizes threads with condition variables. | gxcond |
| deadlock1 | testprog.cpp | A deadlock that gxMutex recovers from automatically. | gxmutex |
| deadlock2 | testprog.cpp | A deadlock that the application recovers from. | gxmutex |
| deadlock_posix_testing | testprog.cpp | POSIX robust mutex deadlock detection test for Linux. | thelpers |
| destroy | testprog.cpp | Destroys a thread. | gxthread |
| detach | testprog.cpp | Creates a detached thread. | gxthread |
| exiting | testprog.cpp | Exits from a thread. | gxthread |
| joined | testprog.cpp | Joins a thread. | gxthread |
| message | testprog.cpp | Thread status and error message functions. | gxthread |
| mutex | testprog.cpp | Protects shared data with gxMutex. | gxmutex |
| priority | testprog.cpp | Sets thread priorities in a thread pool. | thrpool |
| simple | testprog.cpp | Basic gxThread use with entry and exit functions. | gxthread |
| specific | testprog.cpp | Creates thread-specific data. | gthreadt |
| stack | testprog.cpp | Changes a thread's stack size. | gxthread |
| suspend | testprog.cpp | Suspends and resumes a thread. | gxthread |
| template | testprog.cpp | Uses gxThread with templates. | gxthread |
| thread_pool | testprog.cpp | Basic operation of the thread pool. | thrpool |
| timed | testprog.cpp | Synchronizes threads with timing delays. | gxthread |
Security and Regression Tests (6.3 and 6.3.1)
examples_database/run_db_tests.sh (Linux) builds and runs the database examples and every test below that runs on the platform; run_db_tests.bat does the same on Windows (the socket, SSL, stream and protocol tests use fork() and run on UNIX only). Pass 1 for the 64-bit database engine or 0 for the 32-bit engine to the .bat file.
| Folder | Program | What it checks |
|---|---|---|
| examples_database | damaged | Damaged and crafted database files: bad block lengths, checksums, failed opens (6.3). |
| examples_database | infohog | InfoHog/POD example and reopen check (6.3). |
| examples_database | journal | gxdJournal tests: commit, rollback, crash copies, torn journals and checkpoints, readers, the private journal file; crash_test.sh kills a writer with kill -9 (6.3). |
| examples_database | fuzz | libFuzzer targets for .gxd, .btx and journal files (clang; build_fuzz.sh). |
| examples_general | security_sweep | 6.x sweep checks: Base64, gxString, MemoryBuffer, strutil, DiskFileB, futils, parsers, gxRDBMS (6.3, 6.3.1). |
| examples_general | support_security | gxConfig, LogFile, the debug manager, threads, thread messages, SysTime (6.3, 6.3.1). |
| examples_general | print_security | PostScript and HTML print drivers (6.3.1). |
| examples_general | fuzz | libFuzzer targets: config, strings, Base64, HTML, XML, RSS, RDBMS, DiskFileB, MemoryBuffer and other parsers. |
| examples_socket | comm_security | Serial port (pseudo terminal loopback), telnet and ping reply checks (6.3). |
| examples_socket | socket_security | gxSocket: double close, descriptors past FD_SETSIZE, SIGPIPE, I/O timeouts, host addresses (UNIX, 6.3.1). |
| examples_socket | ssl_security | gxSSL: handshake timeout, close, buffered reads, host name check (UNIX, OpenSSL, 6.3.1). |
| examples_socket | stream_security | gxStream and gxDatagram block lengths, 64-bit results, mutual TLS (allow list, refused clients, --open) (UNIX, 6.3.1). |
| examples_socket | proto_security | HTTP, URL, SMTP, POP3, FTP and service file parsers against fake servers (UNIX, 6.3.1). |
| examples_socket | fuzz, stream_fuzz | libFuzzer targets for the protocol parsers and the gxStream peer data (6.3.1). |