-q: quit after EOF on stdin and delay of seconds#

By default, -q is set to 0 to tell pync to quit immediately after reaching EOF (End Of File) on stdin.
If you want to have it wait after EOF, set -q to the number of seconds you want to wait.
Or if you would like to wait forever until the connection closes, set -q to a negative number.

An Example#

  1. Create a test TCP server:

pync -l localhost 8000
py -m pync -l localhost 8000
import pync
pync.run('-l localhost 8000')
  1. Connect to the server with -q set to 5 seconds. This will pipe the message “Hello, World!” into pync’s stdin, then after EOF has been reached on the message, it will wait 5 seconds before closing:

echo "Hello, World!" | pync -q 5 localhost 8000
echo Hello, World! | py -m pync -q 5 localhost 8000
import io
import pync

# io.BytesIO turns our message into a file-like
# object for the pync function.
message = io.BytesIO(b'Hello, World!')
pync.run('-q 5 localhost 8000', stdin=message)


SEE ALSO: