
It seems that the Socket library does still not work with ghc 5.02.1. I tried the simple test:
main = do d <- connectTo "localhost" (PortNumber 80) hPutStr d "GET / HTTP/1.0\n\n" hFlush d c <- hGetContents d putStr c
On Windows2000 I get the known error: *** Exception: does not exist Action: getProtocolByName Reason: no such protocol entry whereas on Linux I get the following error: *** Exception: failed Action: connect Reason: Unknown error 142731264 The error number changes for every invocation and every 20th time or so it works on the linux machine. Can anyone recommend me, how to get a working Socket library with ghc 5.02. (I really need it now...) Sven Eric

In local.glasgow-haskell-users, you wrote:
main = do d <- connectTo "localhost" (PortNumber 80) hPutStr d "GET / HTTP/1.0\n\n" hFlush d c <- hGetContents d putStr c
whereas on Linux I get the following error: *** Exception: failed Action: connect Reason: Unknown error 142731264
Please run the program with 'strace', e.g. strace -o log ./a.out and post the log when it fails. Be aware that 'hGetContents' is broken on 5.02.1 if you use it extensively (the GC will close already-reused fds and cause your program to crash!), the patch was recently postet to -bugs by Simon Marlow and works. OTOH, this is not the bug you're seeing. -- Volker Stolz * stolz@i2.informatik.rwth-aachen.de * PGP + S/MIME

In local.glasgow-haskell-users, you wrote:
It seems that the Socket library does still not work with ghc 5.02.1.
[ghci clarification] There, it crashes for me even on the 2nd invocation: connect(13, {sin_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("137.226.194.33")}}, 16) = -1 EINPROGRESS (Operation now in progress) gettimeofday({1006436761, 219035}, NULL) = 0 select(14, [], [13], NULL, {134, 217727}) = 1 (out [13], left {134, 220000}) getsockopt(13, SOL_SOCKET, SO_ERROR, [1835091456], [1]) = 0 write(1, "*", 1) = 1 whereas on the first, succeeding call to 'connect' it says; select(14, [], [13], NULL, {134, 217727}) = 1 (out [13], left {134, 210000}) getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [1]) = 0 This looks like some on-the-fly bitrotting in ghci :-/ -- Volker Stolz * stolz@i2.informatik.rwth-aachen.de * PGP + S/MIME

"Sven Eric Panitz"
It seems that the Socket library does still not work with ghc 5.02.1. I tried the simple test:
main = do d <- connectTo "localhost" (PortNumber 80) hPutStr d "GET / HTTP/1.0\n\n" hFlush d c <- hGetContents d putStr c
On Windows2000 I get the known error:
*** Exception: does not exist Action: getProtocolByName Reason: no such protocol entry
(You, of course, need to wrap up that code with Socket.withSocketDo to start up WinSock first). FYI, in case you're planning on doing socket programming with GHC-5.02 on a Win32 platform, stay away from using the higher-level Socket module, since its IO.Handle based view of sockets is just broken. Stick with the lower-level SocketPrim interface instead. Specifically, stay away from using the following: * Socket. connectTo * Socket.accept * Socket.sendTo * Socket. recvFrom * SocketPrim.socketToHandle --sigbjorn

Hi all. HDirect can generate code as follows: ------------------------------------------------------------ data CONST_DDWAITVBFLAGS = DDWAITVB_BLOCKBEGIN | DDWAITVB_BLOCKBEGINEVENT | DDWAITVB_BLOCKEND instance Prelude.Enum (CONST_DDWAITVBFLAGS) where fromEnum v = case v of DDWAITVB_BLOCKBEGIN -> 1 DDWAITVB_BLOCKBEGINEVENT -> 2 DDWAITVB_BLOCKEND -> 4 toEnum v = case v of 1 -> DDWAITVB_BLOCKBEGIN 2 -> DDWAITVB_BLOCKBEGINEVENT 4 -> DDWAITVB_BLOCKEND _ -> Prelude.error "unmarshallCONST_DDWAITVBFLAGS: illegal enum value " ------------------------------------------------------------ Unfortunately, if you want to interface to a C function which takes a combination of flags added together in a specific argument eg (C): bar ( DDWAITVB_BLOCKBEGIN + DDWAITVB_BLOCKBEGINEVENT ); (Haskell) bar (toEnum (fromEnum DDWAITVB_BLOCKBEGIN) + (fromEnum DDWAITVB_BLOCKBEGINEVENT )) the toEnum function can't deal with the comnbination - it generates a run-time error. Is there a simple way to deal with this situation (the need to associate symbols with specific values, while retaining the ability to lump the values together in a manner reflecting the underlying C semantics)? Should there be another FFI type CEnum? Should the Haskell Enum type be operable with +/&/| or whatever? Merry Christmas Mike Thomas.

This is just what we agreed on a couple of months ago, no?
I'm afraid this has been sitting on my HDirect ToDo list since
then, as I've been busy with misc other Haskell-related matters.
However, I've unqueued the item & implemented something
which is close to what you're after, I believe. It's just
been checked into the hdirect portion of the CVS repo.
Have a go & let me know whether this scratches your
itch or not.
--sigbjorn
----- Original Message -----
From: "Mike Thomas"
Hi all.
HDirect can generate code as follows:
------------------------------------------------------------ data CONST_DDWAITVBFLAGS = DDWAITVB_BLOCKBEGIN | DDWAITVB_BLOCKBEGINEVENT | DDWAITVB_BLOCKEND
instance Prelude.Enum (CONST_DDWAITVBFLAGS) where fromEnum v = case v of DDWAITVB_BLOCKBEGIN -> 1 DDWAITVB_BLOCKBEGINEVENT -> 2 DDWAITVB_BLOCKEND -> 4
toEnum v = case v of 1 -> DDWAITVB_BLOCKBEGIN 2 -> DDWAITVB_BLOCKBEGINEVENT 4 -> DDWAITVB_BLOCKEND _ -> Prelude.error "unmarshallCONST_DDWAITVBFLAGS: illegal enum value "
------------------------------------------------------------
Unfortunately, if you want to interface to a C function which takes a combination of flags added together in a specific argument eg (C):
bar ( DDWAITVB_BLOCKBEGIN + DDWAITVB_BLOCKBEGINEVENT );
(Haskell)
bar (toEnum (fromEnum DDWAITVB_BLOCKBEGIN) + (fromEnum DDWAITVB_BLOCKBEGINEVENT ))
the toEnum function can't deal with the comnbination - it generates a run-time error.
Is there a simple way to deal with this situation (the need to associate symbols with specific values, while retaining the ability to lump the values together in a manner reflecting the underlying C semantics)?
Should there be another FFI type CEnum?
Should the Haskell Enum type be operable with +/&/| or whatever?
Merry Christmas
Mike Thomas.
participants (6)
-
Mike Thomas
-
Sigbjorn Finne
-
Sigbjorn Finne
-
Sven Eric Panitz
-
Sven Panne
-
Volker Stolz