Revert function names scheme due to the @dom96 comment
This commit is contained in:
parent
862d6ad234
commit
60dbfb2ec9
3 changed files with 16 additions and 40 deletions
|
|
@ -749,7 +749,7 @@ when defined(windows) or defined(nimdoc):
|
||||||
retFuture.complete("")
|
retFuture.complete("")
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc recvBuffer*(socket: AsyncFD, buf: pointer, size: int,
|
proc recvInto*(socket: AsyncFD, buf: pointer, size: int,
|
||||||
flags = {SocketFlag.SafeDisconn}): Future[int] =
|
flags = {SocketFlag.SafeDisconn}): Future[int] =
|
||||||
## Reads **up to** ``size`` bytes from ``socket`` into ``buf``, which must
|
## Reads **up to** ``size`` bytes from ``socket`` into ``buf``, which must
|
||||||
## at least be of that size. Returned future will complete once all the
|
## at least be of that size. Returned future will complete once all the
|
||||||
|
|
@ -769,7 +769,7 @@ when defined(windows) or defined(nimdoc):
|
||||||
verifyPresence(socket)
|
verifyPresence(socket)
|
||||||
assert SocketFlag.Peek notin flags, "Peek not supported on Windows."
|
assert SocketFlag.Peek notin flags, "Peek not supported on Windows."
|
||||||
|
|
||||||
var retFuture = newFuture[int]("recvBuffer")
|
var retFuture = newFuture[int]("recvInto")
|
||||||
|
|
||||||
#buf[] = '\0'
|
#buf[] = '\0'
|
||||||
var dataBuf: TWSABuf
|
var dataBuf: TWSABuf
|
||||||
|
|
@ -816,19 +816,7 @@ when defined(windows) or defined(nimdoc):
|
||||||
retFuture.complete(bytesReceived)
|
retFuture.complete(bytesReceived)
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc recvInto*(socket: AsyncFD, buf: cstring, size: int,
|
proc send*(socket: AsyncFD, buf: pointer, size: int,
|
||||||
flags = {SocketFlag.SafeDisconn}): Future[int] =
|
|
||||||
## Reads **up to** ``size`` bytes from ``socket`` into ``buf``, which must
|
|
||||||
## at least be of that size. Returned future will complete once all the
|
|
||||||
## data requested is read, a part of the data has been read, or the socket
|
|
||||||
## has disconnected in which case the future will complete with a value of
|
|
||||||
## ``0``.
|
|
||||||
##
|
|
||||||
## **Warning**: The ``Peek`` socket flag is not supported on Windows.
|
|
||||||
|
|
||||||
socket.recvBuffer(buf, size, flags)
|
|
||||||
|
|
||||||
proc sendBuffer*(socket: AsyncFD, buf: pointer, size: int,
|
|
||||||
flags = {SocketFlag.SafeDisconn}): Future[void] =
|
flags = {SocketFlag.SafeDisconn}): Future[void] =
|
||||||
## Sends ``size`` bytes from ``buf`` to ``socket``. The returned future will complete once all
|
## Sends ``size`` bytes from ``buf`` to ``socket``. The returned future will complete once all
|
||||||
## data has been sent.
|
## data has been sent.
|
||||||
|
|
@ -1457,9 +1445,9 @@ else:
|
||||||
addRead(socket, cb)
|
addRead(socket, cb)
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc recvBuffer*(socket: AsyncFD, buf: pointer, size: int,
|
proc recvInto*(socket: AsyncFD, buf: pointer, size: int,
|
||||||
flags = {SocketFlag.SafeDisconn}): Future[int] =
|
flags = {SocketFlag.SafeDisconn}): Future[int] =
|
||||||
var retFuture = newFuture[int]("recvBuffer")
|
var retFuture = newFuture[int]("recvInto")
|
||||||
|
|
||||||
proc cb(sock: AsyncFD): bool =
|
proc cb(sock: AsyncFD): bool =
|
||||||
result = true
|
result = true
|
||||||
|
|
@ -1481,7 +1469,7 @@ else:
|
||||||
addRead(socket, cb)
|
addRead(socket, cb)
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc sendBuffer*(socket: AsyncFD, buf: pointer, size: int,
|
proc send*(socket: AsyncFD, buf: pointer, size: int,
|
||||||
flags = {SocketFlag.SafeDisconn}): Future[void] =
|
flags = {SocketFlag.SafeDisconn}): Future[void] =
|
||||||
var retFuture = newFuture[void]("send")
|
var retFuture = newFuture[void]("send")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ template readInto(buf: pointer, size: int, socket: AsyncSocket,
|
||||||
sslRead(socket.sslHandle, cast[cstring](buf), size.cint))
|
sslRead(socket.sslHandle, cast[cstring](buf), size.cint))
|
||||||
res = opResult
|
res = opResult
|
||||||
else:
|
else:
|
||||||
var recvIntoFut = recvBuffer(socket.fd.AsyncFD, buf, size, flags)
|
var recvIntoFut = asyncdispatch.recvInto(socket.fd.AsyncFD, buf, size, flags)
|
||||||
yield recvIntoFut
|
yield recvIntoFut
|
||||||
# Not in SSL mode.
|
# Not in SSL mode.
|
||||||
res = recvIntoFut.read()
|
res = recvIntoFut.read()
|
||||||
|
|
@ -218,7 +218,7 @@ template readIntoBuf(socket: AsyncSocket,
|
||||||
socket.bufLen = size
|
socket.bufLen = size
|
||||||
size
|
size
|
||||||
|
|
||||||
proc recvBuffer*(socket: AsyncSocket, buf: pointer, size: int,
|
proc recvInto*(socket: AsyncSocket, buf: pointer, size: int,
|
||||||
flags = {SocketFlag.SafeDisconn}): Future[int] {.async.} =
|
flags = {SocketFlag.SafeDisconn}): Future[int] {.async.} =
|
||||||
## Reads **up to** ``size`` bytes from ``socket`` into ``buf``.
|
## Reads **up to** ``size`` bytes from ``socket`` into ``buf``.
|
||||||
##
|
##
|
||||||
|
|
@ -318,7 +318,7 @@ proc recv*(socket: AsyncSocket, size: int,
|
||||||
let read = readInto(addr result[0], size, socket, flags)
|
let read = readInto(addr result[0], size, socket, flags)
|
||||||
result.setLen(read)
|
result.setLen(read)
|
||||||
|
|
||||||
proc sendBuffer*(socket: AsyncSocket, buf: pointer, size: int,
|
proc send*(socket: AsyncSocket, buf: pointer, size: int,
|
||||||
flags = {SocketFlag.SafeDisconn}) {.async.} =
|
flags = {SocketFlag.SafeDisconn}) {.async.} =
|
||||||
## Sends ``size`` bytes from ``buf`` to ``socket``. The returned future will complete once all
|
## Sends ``size`` bytes from ``buf`` to ``socket``. The returned future will complete once all
|
||||||
## data has been sent.
|
## data has been sent.
|
||||||
|
|
@ -329,7 +329,7 @@ proc sendBuffer*(socket: AsyncSocket, buf: pointer, size: int,
|
||||||
sslWrite(socket.sslHandle, cast[cstring](buf), size.cint))
|
sslWrite(socket.sslHandle, cast[cstring](buf), size.cint))
|
||||||
await sendPendingSslData(socket, flags)
|
await sendPendingSslData(socket, flags)
|
||||||
else:
|
else:
|
||||||
await sendBuffer(socket.fd.AsyncFD, buf, size, flags)
|
await send(socket.fd.AsyncFD, buf, size, flags)
|
||||||
|
|
||||||
proc send*(socket: AsyncSocket, data: string,
|
proc send*(socket: AsyncSocket, data: string,
|
||||||
flags = {SocketFlag.SafeDisconn}) {.async.} =
|
flags = {SocketFlag.SafeDisconn}) {.async.} =
|
||||||
|
|
|
||||||
|
|
@ -718,7 +718,7 @@ when defined(windows) or defined(nimdoc):
|
||||||
retFuture.complete("")
|
retFuture.complete("")
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc recvBuffer*(socket: AsyncFD, buf: pointer, size: int,
|
proc recvInto*(socket: AsyncFD, buf: pointer, size: int,
|
||||||
flags = {SocketFlag.SafeDisconn}): Future[int] =
|
flags = {SocketFlag.SafeDisconn}): Future[int] =
|
||||||
## Reads **up to** ``size`` bytes from ``socket`` into ``buf``, which must
|
## Reads **up to** ``size`` bytes from ``socket`` into ``buf``, which must
|
||||||
## at least be of that size. Returned future will complete once all the
|
## at least be of that size. Returned future will complete once all the
|
||||||
|
|
@ -738,7 +738,7 @@ when defined(windows) or defined(nimdoc):
|
||||||
verifyPresence(socket)
|
verifyPresence(socket)
|
||||||
assert SocketFlag.Peek notin flags, "Peek not supported on Windows."
|
assert SocketFlag.Peek notin flags, "Peek not supported on Windows."
|
||||||
|
|
||||||
var retFuture = newFuture[int]("recvBuffer")
|
var retFuture = newFuture[int]("recvInto")
|
||||||
|
|
||||||
#buf[] = '\0'
|
#buf[] = '\0'
|
||||||
var dataBuf: TWSABuf
|
var dataBuf: TWSABuf
|
||||||
|
|
@ -785,19 +785,7 @@ when defined(windows) or defined(nimdoc):
|
||||||
retFuture.complete(bytesReceived)
|
retFuture.complete(bytesReceived)
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc recvInto*(socket: AsyncFD, buf: cstring, size: int,
|
proc send*(socket: AsyncFD, buf: pointer, size: int,
|
||||||
flags = {SocketFlag.SafeDisconn}): Future[int] =
|
|
||||||
## Reads **up to** ``size`` bytes from ``socket`` into ``buf``, which must
|
|
||||||
## at least be of that size. Returned future will complete once all the
|
|
||||||
## data requested is read, a part of the data has been read, or the socket
|
|
||||||
## has disconnected in which case the future will complete with a value of
|
|
||||||
## ``0``.
|
|
||||||
##
|
|
||||||
## **Warning**: The ``Peek`` socket flag is not supported on Windows.
|
|
||||||
|
|
||||||
socket.recvBuffer(buf, size, flags)
|
|
||||||
|
|
||||||
proc sendBuffer*(socket: AsyncFD, buf: pointer, size: int,
|
|
||||||
flags = {SocketFlag.SafeDisconn}): Future[void] =
|
flags = {SocketFlag.SafeDisconn}): Future[void] =
|
||||||
## Sends ``size`` bytes from ``buf`` to ``socket``. The returned future will complete once all
|
## Sends ``size`` bytes from ``buf`` to ``socket``. The returned future will complete once all
|
||||||
## data has been sent.
|
## data has been sent.
|
||||||
|
|
@ -1582,9 +1570,9 @@ else:
|
||||||
addRead(socket, cb)
|
addRead(socket, cb)
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc recvBuffer*(socket: AsyncFD, buf: pointer, size: int,
|
proc recvInto*(socket: AsyncFD, buf: pointer, size: int,
|
||||||
flags = {SocketFlag.SafeDisconn}): Future[int] =
|
flags = {SocketFlag.SafeDisconn}): Future[int] =
|
||||||
var retFuture = newFuture[int]("recvBuffer")
|
var retFuture = newFuture[int]("recvInto")
|
||||||
|
|
||||||
proc cb(sock: AsyncFD): bool =
|
proc cb(sock: AsyncFD): bool =
|
||||||
result = true
|
result = true
|
||||||
|
|
@ -1606,7 +1594,7 @@ else:
|
||||||
addRead(socket, cb)
|
addRead(socket, cb)
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc sendBuffer*(socket: AsyncFD, buf: pointer, size: int,
|
proc send*(socket: AsyncFD, buf: pointer, size: int,
|
||||||
flags = {SocketFlag.SafeDisconn}): Future[void] =
|
flags = {SocketFlag.SafeDisconn}): Future[void] =
|
||||||
var retFuture = newFuture[void]("send")
|
var retFuture = newFuture[void]("send")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue