10.01.2020

Install Socat Cygwin

Install Socat Cygwin Rating: 6,9/10 4566 reviews
  1. Install So Cat Centos
Install Socat Cygwin

Install So Cat Centos

Ubuntu

I have a scenario where multiple processes on the same box want to communicate with a serial device. Process A needs two-way communications with the serial port, and Process B only needs to be able to write to the serial port. The serial device is continually spewing data, while the two processes periodically write to the port. The environment is Cygwin on Windows (the processes are windows processes), but the serial port could be moved to a.nix virtual machine if anyone has a Linux-only solution. My 'network diagram' is as follows: /-Process A serial device-ttyS0-socat-udp.

Install

I found a solution. It involves 4 instances of socat, arranged in the network diagram below: /- B - serial adapter C - tcp adapter Process A -/. Socat 'B' talks to the serial port, takes input on stdin and outputs to stdout.

Socat 'A' listens for UDP packets from anywhere and outputs them over stdout, where they are piped into socat 'B'. Where is the serial number on a suzuki quadrunner 250. Socat 'C' listens for a TCP connection from Process A.

Data coming from socat 'A' comes in stdin and is routed to Process A. Data from Process A is sent out stdout to socat 'D'.

Socat 'D' takes data from stdin and sends it out over UDP to socat 'A'. Process B sends UDP packets to socat 'B' when it wants to inject traffic. The bash command to create this monstrosity is as follows: socat -d -d -d -lpAudprxr -u -T5 udp-recv:1111 - 2log.txt socat -d -d -d -lpBserialadapter -t5 - /dev/ttyS0,raw 2log.txt socat -d -d -d -lpCtcpadapter -T5 - tcp4-listen:3333 2log.txt socat -d -d -d -lpDudpsender -u -T5 - udp:localhost:1111,sourceport=2222 2log.txt This also sets a timeout of 5 seconds and logs a lot of detail to 'log.txt'. Port numbers replaced for security.