close sockets in example app

This commit is contained in:
Christian Ulrich 2020-10-07 09:40:51 +02:00
parent 282c0ea6ab
commit 399ad33c99
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 2 additions and 0 deletions

View File

@ -232,6 +232,7 @@ proc runApp(serverHostname: string, serverPort: Port, peerId: string,
let msg = await sock.recv(4) let msg = await sock.recv(4)
echo "received message: ", msg echo "received message: ", msg
await sock.send("pong") await sock.send("pong")
sock.close()
else: else:
# initiate a new connection # initiate a new connection
@ -243,6 +244,7 @@ proc runApp(serverHostname: string, serverPort: Port, peerId: string,
await sock.send("ping") await sock.send("ping")
let msg = await sock.recv(4) let msg = await sock.recv(4)
echo "received message: ", msg echo "received message: ", msg
sock.close()
proc main() = proc main() =
if paramCount() < 3 or paramCount() > 4: if paramCount() < 3 or paramCount() > 4: