add fromFd to asyncutils
This commit is contained in:
parent
b6f28037a0
commit
629556ad30
|
@ -18,6 +18,8 @@ from posix import
|
||||||
CMSG_NXTHDR,
|
CMSG_NXTHDR,
|
||||||
CMSG_LEN,
|
CMSG_LEN,
|
||||||
CMSG_DATA,
|
CMSG_DATA,
|
||||||
|
SOL_SOCKET,
|
||||||
|
SCM_RIGHTS,
|
||||||
sendmsg,
|
sendmsg,
|
||||||
recvmsg
|
recvmsg
|
||||||
|
|
||||||
|
@ -39,6 +41,12 @@ type ControlMessage* = object
|
||||||
msgType*: int
|
msgType*: int
|
||||||
data*: string
|
data*: string
|
||||||
|
|
||||||
|
proc fromFd*(fd: AsyncFD): ControlMessage =
|
||||||
|
result = ControlMessage(level: SOL_SOCKET,
|
||||||
|
msgType: SCM_RIGHTS,
|
||||||
|
data: newString(sizeof(AsyncFD)))
|
||||||
|
cast[ptr AsyncFD](result.data.cstring)[] = fd
|
||||||
|
|
||||||
proc asyncSendMsg*(fd: AsyncFD, data: string,
|
proc asyncSendMsg*(fd: AsyncFD, data: string,
|
||||||
cmsgs: seq[ControlMessage] = @[]): Future[void] =
|
cmsgs: seq[ControlMessage] = @[]): Future[void] =
|
||||||
var retFuture = newFuture[void]("asyncSendMsg")
|
var retFuture = newFuture[void]("asyncSendMsg")
|
||||||
|
|
Loading…
Reference in New Issue