Move checkCloseError to nativesockets

This commit is contained in:
Ruslan Mustakov 2017-02-07 16:45:59 +07:00
commit 7a839d7b02
3 changed files with 32 additions and 25 deletions

View file

@ -1,9 +1,16 @@
discard """
exitcode: 0
output: ""
"""
import asyncdispatch, net, os, nativesockets
# bug: https://github.com/nim-lang/Nim/issues/5279
proc setupServerSocket(hostname: string, port: Port): AsyncFD =
let fd = newNativeSocket()
if fd == osInvalidSocket:
raiseOSError(osLastError())
setSockOptInt(fd, SOL_SOCKET, SO_REUSEADDR, 1)
var aiList = getAddrInfo(hostname, port)
if bindAddr(fd, aiList.ai_addr, aiList.ai_addrlen.Socklen) < 0'i32: