Provide access to getsockname()/getpeername()
Port of #3323 with added tests
This commit is contained in:
parent
a0fb77dfd5
commit
d8ff25f032
2 changed files with 16 additions and 0 deletions
|
|
@ -26,6 +26,10 @@ proc launchSwarm(port: Port) {.async.} =
|
|||
proc readMessages(client: AsyncFD) {.async.} =
|
||||
# wrapping the AsyncFd into a AsyncSocket object
|
||||
var sockObj = newAsyncSocket(client)
|
||||
var (ipaddr, port) = sockObj.getPeerAddr()
|
||||
doAssert ipaddr == "127.0.0.1"
|
||||
(ipaddr, port) = sockObj.getLocalAddr()
|
||||
doAssert ipaddr == "127.0.0.1"
|
||||
while true:
|
||||
var line = await recvLine(sockObj)
|
||||
if line == "":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue