Mentions légales du service

Skip to content

Add support for pseudo-terminal in asebaswitch

Created by: ypiguet-epfl

Improvement suggestion: add an option to asebaswitch to accept a single connection on a pseudo-terminal.

For a clean implementation, this would require a new protocol in Dashel, e.g. serin, which creates a master/slave pair of pseudo-terminals, and a method to get the slave port ("serin:" would create a slave pty, e.g. "/dev/pts/35", and the slave Dashel target would be "ser:device=/dev/pts/35"; similarly for "tcpin:port=40000", the counterpart would be something like "tcp:port=40000").

Code for pseudo-terminals in Linux:

#define _XOPEN_SOURCE	// for pseudoterminal in stdlib.h
#include <stdlib.h>
#include <unistd.h>
masterfd = open("/dev/ptmx", O_RDWR | O_NOCTTY);
if (masterfd < 0)
	error...
if (grantpt(masterfd) < 0)
	error...
if (unlockpt(masterfd) < 0)
	error...
printf("ser:device=%s\n", ptsname(masterfd));	// slave
// communication over masterfd...
close(masterfd);