A Simple one to one chat between a client and a server, meant to be run locally with bidirectional communication sockets.
Some rules:
- The server is waiting for incoming client connections
- When a client terminates a connection, the server continues to wait for another client
- From both side, each message automatically sends back an aknowledgment message with a roundtrip information
- Message are transmitted over the network with each parameter separated by
|. The first parameter represents the type of message (i.eSEND,ACK).
type|sender|body|timestamp
# Examples:
# SEND|bob|how are you|1720619776
# ACK|alice|good|1720619776
#`timestamp` allowing to calculate the `roundtrip time`The application can be start on either client or server mode.
As the project is build with dune, it needs to be built with
dune buildOptionally, there is the possibility to run the build followed by the code formatting with the script build.sh:
./build.shOnce the build is done, the application can be executed either in:
- Server mode with parameter
s:
dune exec simpleClientServerChat s- Client mode with parameter
c:
dune exec simpleClientServerChat cThere is the option to pass a client name, by default it will be "Unknown"
dune exec simpleClientServerChat c "Bob"
- It bas been chosen to use the library
Lwtin order to take benefit ofasynchronous non blocking operations aspect. - The UI is simply the
consoleapplication, but the application uses the library Spectrum to enhance a bit the logs and messages with colors.