about summary refs log tree commit diff stats
path: root/092socket.mu
diff options
context:
space:
mode:
Diffstat (limited to '092socket.mu')
-rw-r--r--092socket.mu20
1 files changed, 7 insertions, 13 deletions
diff --git a/092socket.mu b/092socket.mu
index 202f84a1..5a16a367 100644
--- a/092socket.mu
+++ b/092socket.mu
@@ -106,24 +106,18 @@ def receive-from-socket socket:num, sink:&:sink:char -> sink:&:sink:char, socket
   load-ingredients
   {
     +next-attempt
-    req:text, found?:bool, eof?:bool, error:num <- $read-from-socket socket, 1/byte
+    c:char, found?:bool, eof?:bool, error:num <- $read-from-socket socket
+    break-if eof?
     break-if error
     {
-      break-if found?
-      switch
-      loop +next-attempt
+      break-unless found?
+      sink <- write sink, c
     }
-    bytes-read:num <- length *req
-    i:num <- copy 0
     {
-      done?:bool <- greater-or-equal i, bytes-read
-      break-if done?
-      c:char <- index *req, i  # todo: unicode
-      sink <- write sink, c
-      i <- add i, 1
-      loop
+      break-if found?
+      switch
     }
-    loop-unless eof?
+    loop
   }
   sink <- close sink
 ]