In PandJS, std:net
module provides an asynchronous network API for creating stream-based TCP connections.
TCP echo client
In this code below, client will wait for data from the server and will send this data back.
TCP echo server
Closing TCP connections
There is 2 ways to close connection:
- Graceful with
socket.shutdown
- prefered way of closing connections.
- Aggresive with
socket.destroy
- useful during errors and timeouts.