dest-unreach / socat / contrib / socat-pty

socat patch for pty


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.


This patch is only intended for Linux systems.

Apply this patch to socat source.




Extract the socat source:
tar xzvf socat-

change to the source directory:
cd socat-1.4

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

build socat:
./configure; make


This patch is integrated in socat and later.