Haskell <-> C/C++ comunication (sockets/pipes?)

Sengan senganb@ia.nsc.com
Tue, 25 Sep 2001 20:48:38 -0400


Jorge Adriano wrote:
> 
> Hi all,
> I was thinking about making some GUIs in Qt/KDE for some haskell applications
> (compiled with ghc).
> My first idea was to simply run haskell applications with some args using the
> GUI and get the results from some file or something like that.
> Anyway someone told me that a better idea would be to use pipes to enable the
> GUI to comunicate with the application. I checked the ghc libs and there was
> a
> pipe function, but I would need named pipes here (right?) since the two
> processes are not related. I didn't found any function for that in the ghc
> libs... is there one?
> 
> I was also told that another (better way) to do this would be to use sockets.
> I've worked a little bit with posix stuff (fork, pipes, etc) but I never
> worked
> with sockets.
> 
> I was thinking about using named pipes if that's possible, anyway, Id like to
> know what you think. Is possible. Is sockets a good solution? better? worth
> the trouble of learning how to use them?
> Any better ideas?
> 
> J.A.
> 
> PS: Good luck to the GUI task force ;)


Actually I used unnamed pipes to make it work in Windows, since I needed it to
work both on Unix and Windows. You basically rename the stdin and stdout of the
haskell application into pipes so that the host app can talk to the stdin of the
haskell app, and listen to the stdout of the haskell app. A tip: under Windows,
don't use the "posix functions" Windows provides if you code your app in C/C++:
you'll run out of file handles before you've finished renaming stdin/stdout.
Instead use the Windows functions.

Sengan