about summary refs log tree commit diff stats
path: root/src/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/io')
-rw-r--r--src/io/posixstream.nim10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/io/posixstream.nim b/src/io/posixstream.nim
index 911f384b..0b06c572 100644
--- a/src/io/posixstream.nim
+++ b/src/io/posixstream.nim
@@ -43,6 +43,16 @@ method recvData*(s: PosixStream, buffer: pointer, len: int): int =
     s.isend = true
   return n
 
+proc sreadChar*(s: PosixStream): char =
+  let n = read(s.fd, addr result, 1)
+  if n < 0:
+    raisePosixIOError()
+  if n == 0:
+    if unlikely(s.isend):
+      raise newException(EOFError, "eof")
+    s.isend = true
+  assert n == 1
+
 proc recvData*(s: PosixStream, buffer: var openArray[uint8]): int {.inline.} =
   return s.recvData(addr buffer[0], buffer.len)