{"action":"created","issue":{"url":"https://api.github.com/repos/usocket/usocket/issues/12","repository_url":"https://api.github.com/repos/usocket/usocket","labels_url":"https://api.github.com/repos/usocket/usocket/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/usocket/usocket/issues/12/comments","events_url":"https://api.github.com/repos/usocket/usocket/issues/12/events","html_url":"https://github.com/usocket/usocket/issues/12","id":119374916,"number":12,"title":"Unable to detect a closed socket in a non-blocking way","user":{"login":"phoe","id":15045546,"avatar_url":"https://avatars.githubusercontent.com/u/15045546?v=3","gravatar_id":"","url":"https://api.github.com/users/phoe","html_url":"https://github.com/phoe","followers_url":"https://api.github.com/users/phoe/followers","following_url":"https://api.github.com/users/phoe/following{/other_user}","gists_url":"https://api.github.com/users/phoe/gists{/gist_id}","starred_url":"https://api.github.com/users/phoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phoe/subscriptions","organizations_url":"https://api.github.com/users/phoe/orgs","repos_url":"https://api.github.com/users/phoe/repos","events_url":"https://api.github.com/users/phoe/events{/privacy}","received_events_url":"https://api.github.com/users/phoe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2015-11-29T18:13:43Z","updated_at":"2016-09-24T19:20:34Z","closed_at":null,"body":"The API tells me what to do in two cases:\r\n* ...check whether reading from a socket stream will block, and\r\n* ...check whether the other end has closed my socket stream.\r\n\r\nI find it impossible to:\r\n* ...check whether the other end has closed my socket stream **without blocking**.\r\n\r\nLet's assume a following situation:\r\n```common-lisp\r\n> (defparameter *socket* (socket-listen \"localhost\" 65035)) ;; => *SOCKET*\r\n> (defparameter *stream* (socket-stream (socket-accept (wait-for-input *socket* :timeout 3000)))) ;; => *STREAM* ;after ncat localhost 65035\r\n;; Ctrl-C on the ncat, socket gets closed, OR NOT, socket still open\r\n> (listen *stream*) ;; => NIL\r\n```\r\nIn a situation portrayed above, I should **NOT** do a `(read-line *stream*)` because `(listen *stream*)` gives me a NIL.\r\n\r\nThe issue I see is, `(listen *stream*)` gives a NIL in two cases:\r\n* when there is no data on the stream (usual case),\r\n* when there is an EOF on the stream (problematic case).\r\nAnd I am unable to separate these two cases.\r\n\r\nIn other words: is there any way to separate these two cases mentioned above?\r\nIn 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?"},"comment":{"url":"https://api.github.com/repos/usocket/usocket/issues/comments/249382555","html_url":"https://github.com/usocket/usocket/issues/12#issuecomment-249382555","issue_url":"https://api.github.com/repos/usocket/usocket/issues/12","id":249382555,"user":{"login":"cyclohexanamine","id":13370314,"avatar_url":"https://avatars.githubusercontent.com/u/13370314?v=3","gravatar_id":"","url":"https://api.github.com/users/cyclohexanamine","html_url":"https://github.com/cyclohexanamine","followers_url":"https://api.github.com/users/cyclohexanamine/followers","following_url":"https://api.github.com/users/cyclohexanamine/following{/other_user}","gists_url":"https://api.github.com/users/cyclohexanamine/gists{/gist_id}","starred_url":"https://api.github.com/users/cyclohexanamine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyclohexanamine/subscriptions","organizations_url":"https://api.github.com/users/cyclohexanamine/orgs","repos_url":"https://api.github.com/users/cyclohexanamine/repos","events_url":"https://api.github.com/users/cyclohexanamine/events{/privacy}","received_events_url":"https://api.github.com/users/cyclohexanamine/received_events","type":"User","site_admin":false},"created_at":"2016-09-24T19:20:34Z","updated_at":"2016-09-24T19:20:34Z","body":"For SBCL on Windows, \r\n\r\n    (read-char-no-hang *socket-closed-stream* nil :eof)\r\n\r\nreturns NIL regardless of whether the socket is closed or just blocking. It gives :eof for closed streams on SBCL/Linux and CCL/Linux when I tested those."}}
{"actor":{"display_login":"cyclohexanamine"}}