I am running the simple chat example on the beaglebone, and it turns out the asyncnet leaks connections on a single core CPU. Although the application is no longer running the network port is still locked.
ps output:
root@beaglebone:~/test# ps -ef | grep bone
root 1808 1771 0 11:26 pts/0 00:00:00 grep bone
trying to run:
root@beaglebone:~/test# ./boneRobot
Original stack trace in serve:
Traceback (most recent call last)
boneRobot.nim(160) boneRobot
asyncdispatch.nim(1212) serve
asyncdispatch.nim(1199) cb
boneRobot.nim(101) serveIter
asyncnet.nim(437) bindAddr
os.nim(277) raiseOSError
Continuing...
left - 0.0
right - 0.0
Traceback (most recent call last)
boneRobot.nim(160) boneRobot
asyncdispatch.nim(282) asyncCheck
asyncdispatch.nim(224) callback=
asyncdispatch.nim(286) :anonymous
Error: unhandled exception: Address already in use [Exception]
and netstat:
root@beaglebone:~/test# netstat -an | grep 12345
tcp 0 0 192.168.1.189:12345 192.168.1.2:44488 FIN_WAIT2
root@beaglebone:~/test#
the code is basic:
import asyncnet, asyncdispatch
var clients {.threadvar.}: seq[AsyncSocket]
proc processClient(client: AsyncSocket) {.async.} =
while true:
let line = await client.recvLine()
echo line
#Set some IO pins, no blocking logic here
proc serve() {.async.} =
clients = @[]
var server = newAsyncSocket()
server.bindAddr(Port(12345))
server.listen()
while true:
let client = await server.accept()
clients.add client
asyncCheck processClient(client)
asyncCheck serve()
runForever()