[mercury-users] network programming
Fergus Henderson
fjh at cs.mu.OZ.AU
Tue Mar 10 13:37:22 AEDT 1998
On 09-Mar-1998, Tomas By <T.By at dcs.shef.ac.uk> wrote:
>
> Has anyone thought about network programming in Mercury?
> Seems to me this shouldn't be _that hard_, so presumably
> I'm missing something.
Nope, you're not.
People have not only thought about it, they have in fact done it.
Some folks from the Belgian software company Mission Critical
has written a socket I/O library for Mercury.
Mission Critical's changes to the Mercury library have not yet been
merged back into the standard distribution because of a few concerns
we had about them. See the attached mail.
If anyone wants to do the necessary work to fix their changes up
so that we can incorporate them in our distribution, please go ahead.
In addition, some folks at Inria in France been working on a
debugger / trace analyser for Mercury, where the debugger
communicates with the programming being debugged via a socket.
Erwan Jahier visited Melbourne Uni for about 4 weeks last month,
and while he was here we have been collaborating to implement
the "debuggee" side of that socket interface.
> I suppose
> the way to do it would be to add some socket open/close commands
> to io.m and have them return io__stream:s.
You do need to make some modifications to io.m.
Providing some kind of equivalent to fdopen() in io.m would be
a more generic way of doing this. Then the socket open/close
commands can be in a `socket.m' module.
The other issue you need to address is bidirectional streams.
A simple alternative (the one we used for our debuggee code)
is to have your socket open return a pair of streams, one for
input and one for output.
> Do these things
> vary a lot between platforms? (I know nada about network programming
> under Windoze, for example).
The Windows sockets library interface is basically the same as the
Unix one, I think. I think the only major difference involves
the use of select() to wait on either a socket or something else.
But if you use gnu-win32 (a Unix emulation library for Windows),
then it provides its own socket layer on top of the Windows one
which fixes that too.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the users
mailing list