summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2015-12-14 16:41:12 +0000
committerDominik Picheta <dominikpicheta@googlemail.com>2015-12-14 16:41:12 +0000
commitb012d2f79eb71f834d8b6ebab4424016aab8366a (patch)
tree67ce6c10c3c0f0f59bc9bc3c2b1f0f8addeb15ed
parent1a73cef7654f8adbdd672ba752e9b13b18a170b1 (diff)
parent135668a7ba9ff9bc839a23cd29d08f3323c45530 (diff)
downloadNim-b012d2f79eb71f834d8b6ebab4424016aab8366a.tar.gz
Merge pull request #3641 from qio-io/patch-1
Explicit socket close, and importing the net module
-rw-r--r--lib/pure/redis.nim10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/pure/redis.nim b/lib/pure/redis.nim
index e3f18a496..6741d3c8e 100644
--- a/lib/pure/redis.nim
+++ b/lib/pure/redis.nim
@@ -14,7 +14,7 @@
 ## return ``redisNil``, and functions which return a ``RedisList``
 ## may return ``nil``.
 
-import sockets, os, strutils, parseutils
+import net, os, strutils, parseutils
 
 const
   redisNil* = "\0\0"
@@ -31,7 +31,7 @@ type
 
 type
   Redis* = object
-    socket: Socket
+    socket: net.Socket
     connected: bool
     pipeline: Pipeline
 
@@ -55,9 +55,8 @@ proc newPipeline(): Pipeline =
 
 proc open*(host = "localhost", port = 6379.Port): Redis =
   ## Opens a connection to the redis server.
-  result.socket = socket(buffered = false)
-  if result.socket == invalidSocket:
-    raiseOSError(osLastError())
+  result.socket = newSocket(buffered = false)
+
   result.socket.connect(host, port)
   result.pipeline = newPipeline()
 
@@ -923,6 +922,7 @@ proc quit*(r: Redis) =
   ## Close the connection
   r.sendCommand("QUIT")
   raiseNoOK(r.readStatus(), r.pipeline.enabled)
+  r.socket.close()
 
 proc select*(r: Redis, index: int): RedisStatus =
   ## Change the selected database for the current connection