connectTo fails to fail
System is Linux, Red Hat 7.0.
Ghc version 5.02.
Problem with the connectTo function in package Socket.
If the remote port to which connectTo is trying to
connect is unavailable (i.e. no corresponding process
is bound to that port), the connectTo function neither
throws an exception nor issues a fatal error. The
function simply returns an apparently OK handle (for
which SocketPrim.isConnected also spuriously returns
TRUE).
Using this handle, with something such as hPutStr,
results in a fatal error, logging the message "Broken
pipe".
Example problem at the end of this report.
Apologies if I've gotten this completely wrong.
Many thanks,
Patrick.
--------------------
import BSD
import IO
import Socket
main :: IO ()
main = do hostname <- getHostName
h <- connectTo hostname ((PortNumber .
fromInteger) 9999)
hPutStr h "Hello world"
Trac metadata
Trac field | Value |
---|---|
Version | None |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | ResolvedFixed |
Component | hslibs/net |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |