about summary refs log tree commit diff stats
path: root/src/ips
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-11-27 15:44:42 +0100
committerbptato <nincsnevem662@gmail.com>2022-11-27 15:44:42 +0100
commit3a12afa7617f3ccecbbf6b5852da3d6382a412bb (patch)
tree7596ce7f667b9dabec6ec71c9bd05b9de67feb93 /src/ips
parente7f157c792f53cb084e8694ee608f00727432a3d (diff)
downloadchawan-3a12afa7617f3ccecbbf6b5852da3d6382a412bb.tar.gz
Fix some regressions, add loading progress bar
Diffstat (limited to 'src/ips')
-rw-r--r--src/ips/socketstream.nim9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ips/socketstream.nim b/src/ips/socketstream.nim
index 6ce9bd88..6df9f09b 100644
--- a/src/ips/socketstream.nim
+++ b/src/ips/socketstream.nim
@@ -10,11 +10,18 @@ import ips/serversocket
 
 type SocketStream* = ref object of Stream
   source*: Socket
+  recvw*: bool
   isend: bool
 
 proc sockReadData(s: Stream, buffer: pointer, len: int): int =
   let s = SocketStream(s)
-  result = s.source.recv(buffer, len)
+  try:
+    if s.recvw:
+      result = s.source.recv(buffer, len, 100)
+    else:
+      result = s.source.recv(buffer, len)
+  except TimeoutError:
+    return
   if result < 0:
     raise newException(IOError, "Failed to read data (code " & $osLastError() & ")")
   elif result < len: