diff -r 190661e92e68 Network/Socket.hsc
|
a
|
b
|
|
| 252 | 252 | | Listening -- listen |
| 253 | 253 | | Connected -- connect/accept |
| 254 | 254 | | ConvertedToHandle -- is now a Handle, don't touch |
| | 255 | | Closed -- sClose |
| 255 | 256 | deriving (Eq, Show) |
| 256 | 257 | |
| 257 | 258 | INSTANCE_TYPEABLE0(SocketStatus,socketStatusTc,"SocketStatus") |
| … |
… |
|
| 1991 | 1992 | -- | Closes a socket |
| 1992 | 1993 | sClose :: Socket -> IO () |
| 1993 | 1994 | sClose (MkSocket s _ _ _ socketStatus) = do |
| 1994 | | withMVar socketStatus $ \ status -> |
| 1995 | | if status == ConvertedToHandle |
| 1996 | | then ioError (userError ("sClose: converted to a Handle, use hClose instead")) |
| 1997 | | else c_close s; return () |
| | 1995 | modifyMVar_ socketStatus $ \ status -> |
| | 1996 | case status of |
| | 1997 | ConvertedToHandle -> |
| | 1998 | ioError (userError ("sClose: converted to a Handle, use hClose instead")) |
| | 1999 | Closed -> |
| | 2000 | return status |
| | 2001 | _ -> c_close s >> return Closed |
| 1998 | 2002 | |
| 1999 | 2003 | -- ----------------------------------------------------------------------------- |
| 2000 | 2004 | |