Install Socat Cygwin

The Cygwin 1.7.x devel area offers an older version of GCC (3.4.4-999). Run make install (this will install all the relevant files to the relevant directories).

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:

My first attempt was to set up a socat instance with udp-recvfrom and the fork option. This works for the first packet - a process forks off from socat, sends the data to the serial device, and starts reading data back from the serial device. However, this forked process now has the serial port open for read-write, so no more forks successfully start.

Can anyone think of any way to get this to work? I can think of the following avenues but I haven't found settings to make any of them work:

  • Use socat's udp-recv option to receive from anyone, but find a way to make it send replies to a specific address.
  • Use two unidirectional socats, one to write to the port and one to read from the port. I would then need a way to combine these two unidirectional streams into one bidirectional stream, but I don't know how.
John WalthourJohn Walthour

1 Answer

I found a solution. It involves 4 instances of socat, arranged in the network diagram below:

  • 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'.
  • 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:

This also sets a timeout of 5 seconds and logs a lot of detail to 'log.txt'. Port numbers replaced for security.

John WalthourJohn Walthour

Not the answer you're looking for? Browse other questions tagged cygwinsocat or ask your own question.

I installed the latest version of Cygwin with a number of packages.I soon realised that I need more packages (such as wget, etc) and I couldn't find a way to install the new packages without running the set up again and reinstall everything from scratch.

What I'm looking for is the equivalent of apt-get on Cygwin (if such a thing exists).

MuloneMulone

migrated from stackoverflow.comJun 30 '11 at 15:14

This question came from our site for professional and enthusiast programmers.

8 Answers

There is no package management in Cygwin outside of the setup program. The setup only applies updates to your current installation, it does not overwrite packages that what you already have (unless you have explicitly said so).

So rerun the setup program to install new packages.

Community
Benoit MillerBenoit Miller

There is a package called apt-cyg that may be what you are looking for. It appears to be based upon apt-get.

Socat

apt-cyg is a command-line installer for Cygwin which cooperates with Cygwin Setup and uses the same repository. The syntax is similar to apt-get.

An example command would be

To install it you need wget, tar, gawk, and bzip2. You can download all these packages from the Cygwin packages list.

Socat
random
CheshChesh

Re-run the setup program again. This is how you update Cygwin as well.

BuggabillBuggabill

I find Chocolatey very useful for windows installations management (new, upgrade and removal), and cygwin is no exception!

I installed cygwin using Chocolatey, and since Chocolatey is installing using quiet/silent mode, you are not asked to select any packages and cygwin is installed with bare minimum packages :-(.

However, every time you wish to install a new package it is really-really, easy just use:
--source=cygwin.For example, installing bash:

choco install bash --source=cygwin

Socat Rpm

Socat
Tal TikotzkiTal Tikotzki

Install So Cat Centos

I was stuck with the same issue while trying to use curl on Windows and just got it resolved. Posting it here, now cause it might help someone.

The best way is to just use cygwin's setup.exe and select additional packages that you need. Go here: http://www.cygwin.com/install.html

'When installing packages for the first time, setup*.exe does not install every package. Only the minimal base packages from the Cygwin distribution are installed by default. Clicking on categories and packages in the setup*.exe package installation screen will provide you with the ability to control what is installed or updated.'

Nitin NainNitin Nain

You need to install 'lynx' at first in a common way.Then open cygwin and write this:

  1. lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg

  2. install apt-cyg /bin

Now you can use package manager apt-cyg install

For more information see https://github.com/transcode-open/apt-cyg

AlexAlex

You can use Babun which is built around Cygwin and includes the package manager pact.

Babun supports installing new packages out of the box:

Matthias BraunMatthias Braun

Hi I know that it's old topic but just to add some info:You can also install program called MSYS2 which has the package manager PACMAN from Arch Linux and You are able to install all packs avaible for Arch :)Just pacman -S packageName and hit enter and it will dl it for You:)

Cheers :D

Horacy PigulaHoracy Pigula

Not the answer you're looking for? Browse other questions tagged updatescygwininstallation or ask your own question.

Posted on  by  admin