Skip to content

przemekpjski/AsioClientServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AsioClientServer

---Work in progress---

About

Client-server application using TCP protocol.
Server accepts both IPv6 and IPv4(through v4-mapped-on-v6*) connections.
Both client and server execute on a single thread using Asio's event loop
(which in turn uses epoll system calls - on Linux kernels (v.2.6+); and reactor pattern).

* v4-mapped-on-v6 is not available on Windows XP

Functions:

  • echo command
  • (in progress) chat rooms
  • (todo) a real-time game

ToDo-s:

  • use thread pool in server app to execute the async-op completion handlers concurrently

Usage:

  1. Run the server app
> ./server [listen-port]
  1. Run clients apps
> ./client [server-listen-port] [server-host]

You can close the server app by sending the SIGINT signal to it. Ctrl+C from the terminal running the server in foreground.

You can close the client app by either sending SIGINT to it or by registering a EOF on its input which will terminate the app's command-input loop (Ctrl+D from the terminal running the client in foreground).

Command line arguments default values:

  • listen-port, server-listen-port:  54321
  • server-host:  ::1 (only a valid IPv6 or IPv4 address)

NOTE: the server app listens on all(any) network interfaces (as per in6addr_any on Linux).

Requirements

** due to using POSIX-specific Asio classes for async operations on stdin and stdout
There are, however, Windows-specific counterparts that may be used in this project someday, enabling it to also be run on Windows

Other requirements

  • CMake 3.9+ (build system) with CTest
  • GTest & GMock (when building tests)
  • Doxygen (for generating documentation)

Build instruction

> mkdir build && cd build
> cmake [cmake flags] ..
> make

By default the provided cmake configuration builds and runs all the tests.
You can disable these actions by providing the -DBUILD_TESTING=OFF CMake flag, like so:

> cmake -DBUILD_TESTING=OFF ..

This way only the client and server executables are built.

Run tests

Precondition: build tests. Run make test or ctest from the build directory.

You can also run test executable directly (also from the build dir):

> ./tests [gtest/gmock flags]

This option gives you the possibility to provide additional flags (e.g. to only list test cases names or filter tests to run) and outputs detailed test results.

You can find available command line flags here:

Generate docs

# run in the project root dir
> doxygen docs/Doxyfile

This command with the provided Doxyfile generates html and latex documentation
in the build/docs/html and build/docs/latex directories respectively.

Helpful links for new users

About

TCP client-server app using Asio lib.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published