=================================================== -k: Keep inbound sockets open for multiple connects =================================================== By default, **pync**'s TCP server will accept one client before closing the server's socket. By using the `-k `_ option, you can keep the server open to serve multiple clients one after another. Creating a Date/Time Server =========================== 1. Combining `-k `_ with the `-l `_ and `-e `_ options, we can create a simple date/time server that stays open between connections: .. tab:: Unix .. code-block:: sh pync -kle date localhost 8000 .. tab:: Windows .. code-block:: sh py -m pync -kle "time /t && date /t" localhost 8000 .. tab:: Python .. code-block:: python # datetime_server.py import platform import pync command = 'date' if platform.system() == 'Windows': command = 'time /t && date /t' pync.run('-kle {} localhost 8000'.format(command)) 2. To test this, connect to the server on a separate console: .. tab:: Unix .. code-block:: sh pync localhost 8000 .. tab:: Windows .. code-block:: sh py -m pync localhost 8000 .. tab:: Python .. code-block:: python import pync pync.run('localhost 8000') By setting the **-k** option on the server, you should be able to keep connecting to it to get the current time and date. When you're finished, hit Ctrl+C on the server console to close the server. .. raw:: html

:SEE ALSO: * :doc:`exec` * :doc:`listen`