realised extra parameter was unnecessary

This commit is contained in:
Will Szumski 2014-12-17 23:27:11 +00:00
commit ff24ca9919

View file

@ -430,23 +430,17 @@ proc accept*(server: Socket, client: var Socket,
var addrDummy = "" var addrDummy = ""
acceptAddr(server, client, addrDummy, flags) acceptAddr(server, client, addrDummy, flags)
proc close*(socket: Socket, twoWay = true) = proc close*(socket: Socket) =
## Closes a socket. ## Closes a socket.
##
## When used with a **SSL** socket, `twoWay` can be set to mandate a two-way
## cryptographically secure shutdown, otherwise, a "close notify" shutdown
## alert is sent and the underlying socket is closed without waiting for a response.
## This is acceptable under the TLS standard when the underlying connection is not
## going to be use for further communications.
when defined(ssl): when defined(ssl):
if socket.isSSL: if socket.isSSL:
ErrClearError() ErrClearError()
var res = SSLShutdown(socket.sslHandle) # As we are closing the underlying socket immediately afterwards,
if res == 0 and twoWay: # it is valid, under the TLS standard, to perform a unidirectional
res = SSLShutdown(socket.sslHandle) # shutdown i.e not wait for the peers "close notify" alert with a second
if res != 1: # call to SSLShutdown
socketError(socket, res) let res = SSLShutdown(socket.sslHandle)
elif res == 0: if res == 0:
discard discard
elif res != 1: elif res != 1:
socketError(socket, res) socketError(socket, res)