English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] calling telnet from a caml program
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-11-06 (17:39)
From: Nicolas George <nicolas.george@e...>
Subject: Re: [Caml-list] calling telnet from a caml program
Le sextidi 16 brumaire, an CCXI, Andrei Errapart a écrit :
> If it is possible in C, then it is possible in OCaml, too. Most 
> probably some termios(3) calls are needed, but not much more.

It is More Complicated Than That(tm). On modern Unix, the steps to do
that are:

- master = open(/dev/ptmx)
- grantpt(master)
- unlockpt(master)
- fork
- setsid
- slave = open(ptsname(master))
- ioctl(slave, I_PUSH, "ptem")
- ioctl(slave, I_PUSH, "ldterm")
- ioctl(slave, I_PUSH, "ttcompat")

On BSD, this is more painful, since you must find among /dev/pty*
someone that can be opened, and change ownership of the corresponding
/dev/tty* (so you must be root). The only common step is the

There is nothing impossible, but there are horripilating portability
problems here.