mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 12:07:51 +00:00
asyncnet.nim: Minor code cleanup
This commit is contained in:
@@ -112,7 +112,7 @@ when defineSsl:
|
||||
type
|
||||
# TODO: I would prefer to just do:
|
||||
# AsyncSocket* {.borrow: `.`.} = distinct Socket. But that doesn't work.
|
||||
AsyncSocketDesc = object
|
||||
AsyncSocketDesc = object
|
||||
fd: SocketHandle
|
||||
closed: bool ## determines whether this socket has been closed
|
||||
case isBuffered: bool ## determines whether this socket is buffered.
|
||||
@@ -642,7 +642,7 @@ when defined(posix):
|
||||
when not defined(nimdoc):
|
||||
let retFuture = newFuture[void]("connectUnix")
|
||||
result = retFuture
|
||||
|
||||
|
||||
proc cb(fd: AsyncFD): bool =
|
||||
let ret = SocketHandle(fd).getSockOptInt(cint(SOL_SOCKET), cint(SO_ERROR))
|
||||
if ret == 0:
|
||||
@@ -653,7 +653,7 @@ when defined(posix):
|
||||
else:
|
||||
retFuture.fail(newException(OSError, osErrorMsg(OSErrorCode(ret))))
|
||||
return true
|
||||
|
||||
|
||||
var socketAddr = makeUnixAddr(path)
|
||||
let ret = socket.fd.connect(cast[ptr SockAddr](addr socketAddr),
|
||||
(sizeof(socketAddr.sun_family) + path.len).Socklen)
|
||||
@@ -683,7 +683,7 @@ elif defined(nimdoc):
|
||||
## Binds Unix socket to `path`.
|
||||
## This only works on Unix-style systems: Mac OS X, BSD and Linux
|
||||
discard
|
||||
|
||||
|
||||
proc bindUnix*(socket: AsyncSocket, path: string) =
|
||||
## Binds Unix socket to `path`.
|
||||
## This only works on Unix-style systems: Mac OS X, BSD and Linux
|
||||
|
||||
Reference in New Issue
Block a user