A simple client server utility that blocks until a message is received on a TCP/IP socket connection
Project description
wait-for-message
A simple client server utility that blocks until a message is received on a TCP/IP socket connection; useful for synchronizing interdependent networked jobs.
Installation
pip install wait-for-message
w4m
Usage
usage: w4m [-h] {send,wait} ...
A simple client server utility that blocks until a message is received on a TCP/IP socket connection
positional arguments:
{send,wait}
send send message to server
wait wait for message from client
optional arguments:
-h, --help show this help message and exit
w4m send
usage: w4m send [-h] --ip-address IP_ADDRESS --port-number PORT_NUMBER --message MESSAGE_TO_SEND [--delay DELAY] [--attempts MAX_ATTEMPTS]
optional arguments:
-h, --help show this help message and exit
--ip-address IP_ADDRESS
the ip address of the server
--port-number PORT_NUMBER
the port number the server is listening on
--message MESSAGE_TO_SEND
the message to send
--delay DELAY number of seconds to delay between retries; default 10
--attempts MAX_ATTEMPTS
maximum retry attempts; default 6
w4m wait
usage: w4m wait [-h] --port-number PORT_NUMBER --message MESSAGE_TO_WAIT_FOR [--timeout TIMEOUT]
optional arguments:
-h, --help show this help message and exit
--port-number PORT_NUMBER
the port number the server is listening on
--message MESSAGE_TO_WAIT_FOR
the message to wait for
--timeout TIMEOUT number of seconds to wait for message; default 900 (i.e. 15 minutes)
Example
server
On a Linux machine, start tcp/ip socket listening on port 8080 and wait for message. Note the script blocks until the expected message is received.
w4m wait --port-number 8080 --message 'ready to proceed'
client
On an other machine (this example we used a Windows machine), connect tcip/ip socket to the ip:port for the server and send several messages.
w4m send --ip-address 192.168.1.199 --port-number 8080 --message "a message"
w4m send --ip-address 192.168.1.199 --port-number 8080 --message "another message"
w4m send --ip-address 192.168.1.199 --port-number 8080 --message "ready to proceed"
Development
Build the Docker image:
docker image build \
-t \
w4m:latest .
Run the Docker container:
docker container run \
--rm \
-it \
-v $PWD:/code \
-p:8080:8080 \
w4m:latest \
bash
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wait-for-message-0.1.1.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for wait_for_message-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbf48e472fee2d39a2cf8a086700259eda692101e23d2e7bd0d97a7a94a0ac59 |
|
MD5 | 2104f94895f3b21ce323ac35baff4fef |
|
BLAKE2b-256 | d6e8d94700c0546d4a6f47c1ef1a43f13f5adc7d92c6174936fadc9c60ae2171 |