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

Eray Ozkural (exa) erayo@cs.bilkent.edu.tr
Wed, 26 Sep 2001 06:38:05 +0300


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Jorge,

This is exa from #kde :)

Using stdin/stdout with ASCII first would be certainly easier. All you have 
to do is to define some GUI commands. Then if you convert to some binary 
interface, you could again use either pipes or sockets.

I'd referred to this function on irc, but anyway. In posix category.

createNamedPipe :: FilePath -> FileMode -> IO ()

createNamedPipe fifo mode calls mkfifo to create a new named pipe, fifo, with 
permissions based on mode.

And of course you could create that fifo externally with a shell script if 
you'd like and run stuff from there. I'd almost certainly make it run over 
stdin/stdout on second thought. You do the connection externally as Sengan 
says. Create the pipes. fork the program. connect the stdin/stdout of child 
to your pipes. I think he did it writing C code, but you could also do it 
using bash, right?

#! /bin/sh
mkfifo input
mkfifo output
app <input >output &
guifrontend >input <output

Not exactly what the C code would do, but something like that should work for 
you. Making it run with stdin/stdout also gives you an incentive to make your 
program into an interactive shell!
$ app
info: This is a really cool AI expert system, version 3.0.2
info: bla bla
> help
info: valid commands: instance property...
> ....

Hmm. This gives me a few ideas for my own project, too.

I don't think that you absolutely need to do this with sockets. Many decent 
applications use pipes. :)

Since you will be using KDE, you don't have to worry too much about Windows.
Unless of course one day you want to port it. :) Then you might consider 
writing another such GUI using MFC with Visual C++. And make it an ActiveX 
component, get it signed by MS, etc, etc. Or, alternatively port a large 
portion of KDE to windows.

Regards,

- -- 
Eray Ozkural (exa) <erayo@cs.bilkent.edu.tr>
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE7sU2hfAeuFodNU5wRArSXAJ9WbV4q6JV9v0HfZbgHLwzlanHrhQCfaskh
yP4d449k8bh/YJehcObuYEg=
=YjR8
-----END PGP SIGNATURE-----