
Quoth C K Kashyap
I am using http://hackage.haskell.org/package/connection. So I create network connection in Haskell
getConnection :: IO Connection
I'd like this connection to be returned to C so that subsequent calls from C can send in the connection handle.
According to the documentation, he doesn't export enough of the Connection type to access the handle inside, and there appears to be no function provided to do that either. So it looks to me like you'd have to 1) make the connection "by hand" with Network.Socket.connect etc., 2) get the Socket fd, 3) make a Handle from the Socket, 4) pass that to connectFromHandle, and 5) use the fd with your C function. Note that the socket connection itself, represented by the fd that you return to C, will simply transmit data back and forth without modification. Specifically without SSL encryption. If you need SSL encryption in both Haskell and C, it would probably be simpler to implement the I/O in C and call it from Haskell. Donn