2020-01-13 09:40:14 +00:00
|
|
|
# UDPConnection
|
|
|
|
|
|
|
|
Provides a network connection over UDP, with verification of packet support via
|
2020-01-13 10:14:34 +00:00
|
|
|
libsodium (optional). Implemented in C++ (up to C++11 standard), but is
|
|
|
|
available via a C api, which should facilitate creating bindings for other
|
|
|
|
programming languages if needed.
|
2020-01-13 09:40:14 +00:00
|
|
|
|
2023-07-03 03:03:52 +00:00
|
|
|
~~This library is still a work in progress, so api breaking changes may happen
|
|
|
|
in the future.~~
|
|
|
|
This library is usable. Try testing it out using the `NetworkTest` binary which
|
|
|
|
is built when Debug builds are enabled (the default) with CMake.
|
|
|
|
|
|
|
|
$ ./NetworkTest
|
|
|
|
[-c | -s] - client or server (default server)
|
|
|
|
-ll <addr> - listen addr
|
|
|
|
-lp <port> - listen port
|
|
|
|
-cl <addr> - connection addr (client only)
|
|
|
|
-clh <hostname> - connection hostname (client only)
|
|
|
|
-cp <port> - connection port (client only)
|
|
|
|
-t <tick_count>
|
|
|
|
-n - do not add payload to packets
|
|
|
|
-l (silent|error|warning|info|verbose|debug) - log level, default debug
|
|
|
|
-e - enable receiving events
|
|
|
|
-ls - enable libsodium
|
|
|
|
-ck <pubkey_file> - add pubkey to whitelist
|
|
|
|
-sk <pubkey> <seckey> - start with pub/sec key pair
|
|
|
|
-p <"fallback" or "strict"> - set auth policy
|
|
|
|
--hostname <hostname> - dont run test, just lookup hostname
|
|
|
|
|
|
|
|
A typical test can be done with the following parameters:
|
|
|
|
|
|
|
|
Server:
|
|
|
|
|
|
|
|
./NetworkTest -s -ll ::1 -lp 9000 -t 50 -e
|
|
|
|
|
|
|
|
Client:
|
|
|
|
|
|
|
|
./NetworkTest -c -ll ::1 -lp 9001 -cl ::1 -cp 9000 -t 40 -e
|
|
|
|
|
|
|
|
`NetworkTest` gracefully shuts down on SIGINT (Ctrl-C).
|
|
|
|
|
|
|
|
The source of `NetworkTest` can be found in `src/test/UDPC_NetworkTest.c`.
|
2020-01-13 09:40:14 +00:00
|
|
|
|
2020-01-13 09:50:00 +00:00
|
|
|
## Documentation
|
|
|
|
|
2021-09-09 09:13:38 +00:00
|
|
|
[See the gh-pages generated Doxygen documentation here.](https://stephen-seo.github.io/UDPConnection/)
|
2020-01-13 09:50:00 +00:00
|
|
|
|
2023-12-19 03:59:10 +00:00
|
|
|
[Alternatively, see the generated Doxygen documentation on my website.](https://seodisparate.com/udpc_docs)
|
|
|
|
|
2020-01-13 09:40:14 +00:00
|
|
|
## Compiling
|
|
|
|
|
2020-01-13 10:26:05 +00:00
|
|
|
### Release builds
|
|
|
|
|
2020-01-13 09:40:14 +00:00
|
|
|
mkdir buildRelease
|
|
|
|
cd buildRelease
|
|
|
|
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=True ..
|
|
|
|
make
|
|
|
|
make DESTDIR=install_destination install
|
2020-01-13 09:47:22 +00:00
|
|
|
|
2020-01-13 10:26:05 +00:00
|
|
|
### Debug builds
|
|
|
|
|
|
|
|
mkdir buildDebug
|
|
|
|
cd buildDebug
|
|
|
|
cmake -DCMAKE_BUILD_TYPE=Debug ..
|
|
|
|
make
|
|
|
|
|
2020-01-13 09:47:22 +00:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
The program in `src/test/UDPC_NetworkTest.c` is used for testing UDPConnection
|
|
|
|
and is also an example of using the library in a C program.
|
2020-01-13 10:14:34 +00:00
|
|
|
|
|
|
|
## Debug Builds
|
|
|
|
|
|
|
|
NetworkTest only builds when CMAKE\_BUILD\_TYPE is Debug (default).
|
|
|
|
|
|
|
|
UnitTest only builds in Debug mode and if GTest (a unit testing framework) is
|
|
|
|
available.
|
2021-02-14 04:56:26 +00:00
|
|
|
|
|
|
|
# Links
|
|
|
|
https://github.com/Stephen-Seo/UDPConnection
|
2021-08-25 10:45:01 +00:00
|
|
|
https://git.seodisparate.com/stephenseo/UDPConnection
|
2023-07-19 02:35:28 +00:00
|
|
|
|
|
|
|
# Other Notes
|
|
|
|
|
|
|
|
Inspired by [a series of blog posts about networking for games.](https://gafferongames.com/categories/game-networking/)
|