Open
Description
The API tells me what to do in two cases:
- ...check whether reading from a socket stream will block, and
- ...check whether the other end has closed my socket stream.
I find it impossible to:
- ...check whether the other end has closed my socket stream without blocking.
Let's assume a following situation:
> (defparameter *socket* (socket-listen "localhost" 65035)) ;; => *SOCKET*
> (defparameter *stream* (socket-stream (socket-accept (wait-for-input *socket* :timeout 3000)))) ;; => *STREAM* ;after ncat localhost 65035
;; Ctrl-C on the ncat, socket gets closed, OR NOT, socket still open
> (listen *stream*) ;; => NIL
In a situation portrayed above, I should NOT do a (read-line *stream*)
because (listen *stream*)
gives me a NIL.
The issue I see is, (listen *stream*)
gives a NIL in two cases:
- when there is no data on the stream (usual case),
- when there is an EOF on the stream (problematic case).
And I am unable to separate these two cases.
In other words: is there any way to separate these two cases mentioned above?
In yet other words: in the situation portrayed within the code block, what command will reliably tell me whether the NIL given to me by the (listen *socket*)
is because of lack of data or an EOF?
Metadata
Metadata
Assignees
Labels
No labels