asyncnet.nim: Minor code cleanup
This commit is contained in:
parent
2fae94cdc5
commit
315d438677
1 changed files with 4 additions and 4 deletions
|
|
@ -112,7 +112,7 @@ when defineSsl:
|
||||||
type
|
type
|
||||||
# TODO: I would prefer to just do:
|
# TODO: I would prefer to just do:
|
||||||
# AsyncSocket* {.borrow: `.`.} = distinct Socket. But that doesn't work.
|
# AsyncSocket* {.borrow: `.`.} = distinct Socket. But that doesn't work.
|
||||||
AsyncSocketDesc = object
|
AsyncSocketDesc = object
|
||||||
fd: SocketHandle
|
fd: SocketHandle
|
||||||
closed: bool ## determines whether this socket has been closed
|
closed: bool ## determines whether this socket has been closed
|
||||||
case isBuffered: bool ## determines whether this socket is buffered.
|
case isBuffered: bool ## determines whether this socket is buffered.
|
||||||
|
|
@ -642,7 +642,7 @@ when defined(posix):
|
||||||
when not defined(nimdoc):
|
when not defined(nimdoc):
|
||||||
let retFuture = newFuture[void]("connectUnix")
|
let retFuture = newFuture[void]("connectUnix")
|
||||||
result = retFuture
|
result = retFuture
|
||||||
|
|
||||||
proc cb(fd: AsyncFD): bool =
|
proc cb(fd: AsyncFD): bool =
|
||||||
let ret = SocketHandle(fd).getSockOptInt(cint(SOL_SOCKET), cint(SO_ERROR))
|
let ret = SocketHandle(fd).getSockOptInt(cint(SOL_SOCKET), cint(SO_ERROR))
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
|
|
@ -653,7 +653,7 @@ when defined(posix):
|
||||||
else:
|
else:
|
||||||
retFuture.fail(newException(OSError, osErrorMsg(OSErrorCode(ret))))
|
retFuture.fail(newException(OSError, osErrorMsg(OSErrorCode(ret))))
|
||||||
return true
|
return true
|
||||||
|
|
||||||
var socketAddr = makeUnixAddr(path)
|
var socketAddr = makeUnixAddr(path)
|
||||||
let ret = socket.fd.connect(cast[ptr SockAddr](addr socketAddr),
|
let ret = socket.fd.connect(cast[ptr SockAddr](addr socketAddr),
|
||||||
(sizeof(socketAddr.sun_family) + path.len).Socklen)
|
(sizeof(socketAddr.sun_family) + path.len).Socklen)
|
||||||
|
|
@ -683,7 +683,7 @@ elif defined(nimdoc):
|
||||||
## Binds Unix socket to `path`.
|
## Binds Unix socket to `path`.
|
||||||
## This only works on Unix-style systems: Mac OS X, BSD and Linux
|
## This only works on Unix-style systems: Mac OS X, BSD and Linux
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc bindUnix*(socket: AsyncSocket, path: string) =
|
proc bindUnix*(socket: AsyncSocket, path: string) =
|
||||||
## Binds Unix socket to `path`.
|
## Binds Unix socket to `path`.
|
||||||
## This only works on Unix-style systems: Mac OS X, BSD and Linux
|
## This only works on Unix-style systems: Mac OS X, BSD and Linux
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue