dest-unreach / socat / contrib / socat-pty

socat patch for pty

Background

In the German computer magazin Heise c't 2004/13, page 200, socat is used for redirecting a pty via TCP to a TCP-to-serial interface. The socat invocation looks something like socat pty tcp:ip-address:ip-port". Because the "pty" implementation of socat does not wait until a process opens the ptys slave side, it immediately opens the TCP connection and thus blocks the remote interface.

This patch changes the behaviour of socats pty address. It waits for a connection to the ptys slave side and only then proceeds to handling the next address.

This current solution polls the pty state until the POLL_HUP condition ends. The polling intervall is hardcoded to one second; change the value of INTERVALL in xio-pty.c if required.

Requisites

This patch is only intended for Linux systems.

Apply this patch to socat 1.4.0.2 source.

Download

socat-pty.patch.gz

Deployment

Extract the socat 1.4.0.2 source:
tar xzvf socat-1.4.0.2.tar.gz

change to the source directory:
cd socat-1.4

apply the patch:
gunzip <../socat-pty.patch.gz |patch

build socat:
./configure; make

Status

This patch is integrated in socat 1.4.1.0 and later.