Fix compilation of the deprecated sockets module hackishly.
This commit is contained in:
parent
88b65ea957
commit
96eef6d789
1 changed files with 4 additions and 2 deletions
|
|
@ -42,6 +42,8 @@ from times import epochTime
|
||||||
|
|
||||||
when defined(ssl):
|
when defined(ssl):
|
||||||
import openssl
|
import openssl
|
||||||
|
else:
|
||||||
|
type SSLAcceptResult = int
|
||||||
|
|
||||||
when defined(Windows):
|
when defined(Windows):
|
||||||
import winlean
|
import winlean
|
||||||
|
|
@ -492,7 +494,7 @@ proc getSockName*(socket: Socket): Port =
|
||||||
raiseOSError(osLastError())
|
raiseOSError(osLastError())
|
||||||
result = Port(sockets.ntohs(name.sin_port))
|
result = Port(sockets.ntohs(name.sin_port))
|
||||||
|
|
||||||
template acceptAddrPlain(noClientRet, successRet: int,
|
template acceptAddrPlain(noClientRet, successRet: SSLAcceptResult or int,
|
||||||
sslImplementation: untyped): untyped =
|
sslImplementation: untyped): untyped =
|
||||||
assert(client != nil)
|
assert(client != nil)
|
||||||
var sockAddress: Sockaddr_in
|
var sockAddress: Sockaddr_in
|
||||||
|
|
@ -549,7 +551,7 @@ proc acceptAddr*(server: Socket, client: var Socket, address: var string) {.
|
||||||
##
|
##
|
||||||
## **Warning:** When using SSL with non-blocking sockets, it is best to use
|
## **Warning:** When using SSL with non-blocking sockets, it is best to use
|
||||||
## the acceptAddrSSL procedure as this procedure will most likely block.
|
## the acceptAddrSSL procedure as this procedure will most likely block.
|
||||||
acceptAddrPlain(-1, -1):
|
acceptAddrPlain(SSLAcceptResult(-1), SSLAcceptResult(-1)):
|
||||||
when defined(ssl):
|
when defined(ssl):
|
||||||
if server.isSSL:
|
if server.isSSL:
|
||||||
# We must wrap the client sock in a ssl context.
|
# We must wrap the client sock in a ssl context.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue