Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Network/Socket.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,10 @@ close (MkSocket s _ _ _ socketStatus) = do

-- -----------------------------------------------------------------------------

-- | Determines whether 'close' has been used on the 'Socket'. This
-- does /not/ indicate any status about the socket beyond this. If the
-- socket has been closed remotely, this function can still return
-- 'True'.
isConnected :: Socket -> IO Bool
isConnected (MkSocket _ _ _ _ status) = do
value <- readMVar status
Expand Down
17 changes: 11 additions & 6 deletions Network/Socket/Types.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,19 @@ instance Show Socket where

type ProtocolNumber = CInt

-- | The status of the socket as /determined by this library/, not
-- necessarily reflecting the state of the connection itself.
--
-- For example, the 'Closed' status is applied when the 'close'
-- function is called.
data SocketStatus
-- Returned Status Function called
= NotConnected -- socket
| Bound -- bind
| Listening -- listen
| Connected -- connect/accept
| ConvertedToHandle -- is now a Handle, don't touch
| Closed -- close
= NotConnected -- ^ Newly created, unconnected socket
| Bound -- ^ Bound, via 'bind'
| Listening -- ^ Listening, via 'listen'
| Connected -- ^ Connected or accepted, via 'connect' or 'accept'
| ConvertedToHandle -- ^ Is now a 'Handle' (via 'socketToHandle'), don't touch
| Closed -- ^ Closed was closed by 'close'
deriving (Eq, Show, Typeable)

-----------------------------------------------------------------------------
Expand Down