From 8ff599746796d91e7fb0daf9c7c6b8ca24bf0c09 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 27 Jan 2018 19:09:31 +0100 Subject: [PATCH] Added README.md --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..0a2320c --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# Exemple + +2 machines (A and B) want to share an INPUT/OUTPUT communication in bash. +- Machine B: 10.10.10.10 port 1111 +- Machine A: 20.20.20.20 port 2222 + +### On machine B + +First of all because each machine will launch a **client** and a **server**, because of cyclic-redondency, we have to synchronise them so that the _clients_ are connected after the 2 _servers_. + +We can use the 'trigger' to do such synchronisation. It waits until it receives (through a choosen port) a message from machine A. + +```bash +./trigger 9999; ./launch machineB 20.20.20.20 2222 1111 +``` +So we are listening on port _9999_ waiting for machine A to tell us when to start. + +The arguments can be read through this sentence "I will connect to `20.20.20.20` at port `2222` and my port `1111` is available." + + +### On machine A + +You can notice that it is the reverse command from machine B, but we have to launch the trigger instead of waiting for it. The last optional parameter of 'launch' is made for that purpose. + +```bash +./launch machineA 10.10.10.10 1111 2222 9999; +``` +Now the server will start as expected and stop the 'trigger' command on machine B so it will also launch the server on it. After a delay of 2 seconds, the 2 servers might be connected to each other. + + + +### Send a message + +```bash +./write {sender_machine} "some_message\n"; +``` + + + +### Read messages + +```bash +./read {sender_machine}; +``` +Note: After a 'read' call, the buffer will be flushed (reading = consuming). \ No newline at end of file