{"action":"opened","issue":{"url":"https://api.github.com/repos/haskell/network/issues/169","labels_url":"https://api.github.com/repos/haskell/network/issues/169/labels{/name}","comments_url":"https://api.github.com/repos/haskell/network/issues/169/comments","events_url":"https://api.github.com/repos/haskell/network/issues/169/events","html_url":"https://github.com/haskell/network/issues/169","id":82423611,"number":169,"title":"`send` should check socket status and fail if the socket is closed","user":{"login":"Yuras","id":692251,"avatar_url":"https://avatars.githubusercontent.com/u/692251?v=3","gravatar_id":"","url":"https://api.github.com/users/Yuras","html_url":"https://github.com/Yuras","followers_url":"https://api.github.com/users/Yuras/followers","following_url":"https://api.github.com/users/Yuras/following{/other_user}","gists_url":"https://api.github.com/users/Yuras/gists{/gist_id}","starred_url":"https://api.github.com/users/Yuras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yuras/subscriptions","organizations_url":"https://api.github.com/users/Yuras/orgs","repos_url":"https://api.github.com/users/Yuras/repos","events_url":"https://api.github.com/users/Yuras/events{/privacy}","received_events_url":"https://api.github.com/users/Yuras/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-29T13:16:40Z","updated_at":"2015-05-29T13:16:40Z","closed_at":null,"body":"The `Network.Socket.close` claims that\r\n\r\n> All future operations on the socket object will fail\r\n\r\nIt changes socket state to `Closed` and calls `close(2)` C function, so OS is free to reuse the FD.\r\n\r\nBut `Network.Socket.send` and friends don't check socket status. When sending data to a closed socket usually an exception is thrown (`close(2)` returns `EBADF`), but there is a chance that the FD is reused after `close` but before `send`, so the data will be silently sent to a wrong destination.\r\n\r\nOne can argue that writing to a closed socket is a bad practice anyway, then please consider it as a documentation bug."}}