Questions tagged [socat]

socat is a relay for bidirectional data transfer between two independent data channels.

socat is a relay for bidirectional data transfer between two independent data channels. Each of these data channels may be a file, pipe, device (serial line etc. or a pseudo terminal), a socket (UNIX, IP4, IP6 - raw, UDP, TCP), an SSL socket, proxy CONNECT connection, a file descriptor (stdin etc.), the GNU line editor (readline), a program, or a combination of two of these. These modes include generation of "listening" sockets, named pipes, and pseudo terminals.

socat can be used, e.g., as TCP port forwarder (one-shot or daemon), as an external socksifier, for attacking weak firewalls, as a shell interface to UNIX sockets, IP6 relay, for redirecting TCP oriented programs to a serial line, to logically connect serial lines on different computers, or to establish a relatively secure environment (su and chroot) for running client or server shell scripts with network connections.

Many options are available to refine socats behaviour: terminal parameters, open() options, file permissions, file and process owners, basic socket options like bind address, advanced socket options like IP source routing, linger, TTL, TOS (type of service), or TCP performance tuning.

More capabilities, like daemon mode with forking, client address check, "tail -f" mode, some stream data processing (line terminator conversion), choosing sockets, pipes, or ptys for interprocess communication, debug and trace options, logging to syslog, stderr or file, and last but not least precise error messages make it a versatile tool for many different purposes.

In fact, many of these features already exist in specialized tools; but until now, there does not seem to exists another tool that provides such a generic, flexible, simple and almost comprehensive (UNIX) byte stream connector.

282 questions
30
votes
3 answers

How do I connect to a websocket manually, with netcat/socat/telnet?

I am trying to connect to the reference websocket echo server "manually", in order to learn how the protocol works (I am using socat for that). However, the server invariably closes the connection without providing an answer. Any idea why? Here is…
user48678
  • 2,382
  • 3
  • 24
  • 30
23
votes
2 answers

Install Socat on Mac

I would like to know how can I install Socat on my Mac (lion) ? I tried to find an How To via Google but I didn't find anything. Thank you in advance!
Ilan
  • 569
  • 1
  • 8
  • 21
20
votes
1 answer

Why is "fork" needed by socat when connecting to a web server?

I am trying to understand tcp connections between a browser and a web server. I have a web server running on my local machine, and can browse to it just fine, as expected, using localhost:3000 or 127.0.0.1:3000. (I am running "rails s"and…
user691307
  • 485
  • 2
  • 5
  • 15
20
votes
4 answers

socat port forwarding for https

I can use socat for the port forwarding like this: socat TCP4-LISTEN:8080 TCP4:123.456.789.12:80 In this case, it works perfectly: all http-requests to localhost:8080 will be redirected to 123.456.789.12:80. But how can I use such forwarding for…
Denis Shevchenko
  • 1,342
  • 2
  • 10
  • 23
19
votes
3 answers

socat fake http server - use a file as server response

I've been trying to use socat to respond on each connection to a socket it's listening to with a fake HTTP reply. I cannot get it working. It might be because I'm using the cygwin version of socat? I don't know. Part of the problem is I want the…
loop
  • 3,460
  • 5
  • 34
  • 57
17
votes
2 answers

kubectl port-forward connection refused [ socat ]

I am running pyspark on one of the ports of kubernetes. I am trying to port forward to my local machine. I am getting this error while executing my python file. Forwarding from 127.0.0.1:7077 -> 7077 Forwarding from [::1]:7077 -> 7077 Handling…
Ruchit Dalwadi
  • 311
  • 1
  • 2
  • 13
17
votes
3 answers

Running GUI apps on docker container with a MacBookPro host

I have been trying to follow the instructions on https://learning-continuous-deployment.github.io/docker/images/dockerfile/2015/04/22/docker-gui-osx/ about running GUI apps in a docker container inside a MacBookPro host (using Docker tools). I…
emory
  • 10,725
  • 2
  • 30
  • 58
14
votes
3 answers

Recording messages received on a port with SOCAT

I have a server with an open port which receives between 50 and 1000 messages per second. By message I mean that a single line of text is sent. Essentially we want to record these messages in a file which will be processed every hour (or x…
user1844937
  • 321
  • 1
  • 2
  • 6
13
votes
2 answers

How to test a remote port is reachable with socat

How to test a remote port is reachable with socat? with netcat we can nc -zv 192.168.1.15 22 How to do that with socat?
w1100n
  • 1,460
  • 2
  • 17
  • 24
13
votes
1 answer

Null modem emulator (com0com) for linux

I have a project that contains some unitary tests used to test the serial communications using COM ports (in windows). I use com0com to create a virtual pair of bounded ports and execute the tests. However I don't know how to do that in Linux…
PedroD
  • 5,670
  • 12
  • 46
  • 84
13
votes
1 answer

Emulate serial port

Is it possible to create a "virtual" serial device that sends data through a "virtual" serial port? I need to develop some code to interact with an Arduino but don't have it with me. Can it be done with socat, or some code that writes to a…
joaocandre
  • 1,621
  • 4
  • 25
  • 42
12
votes
2 answers

Pyserial does not play well with virtual port

Motivation I want to start leraning how to use the python library Pyserial. It seems like a really nice library that works for a lot of people. I want to use it for an upcoming project in which I have to automate serial…
11
votes
1 answer

Socat terminates after connection close

This comand (serial port redirector) accepts a single connection on TCP:11313 : socat PTY,link=/dev/ttyV1,echo=0,raw,unlink-close=0 TCP-LISTEN:11313,forever,reuseaddr However when the connection is lost, the above socat process is killed and the…
DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
10
votes
1 answer

socat - how to listen on non-ssl TCP and forward to ssl TCP endpoint?

I have seen an example of using socat to accept ssl TCP traffic and forward the traffic to a non-ssl host: socat TCP-LISTEN:443,reuseaddr,fork "^OPENSSL-SERVER,cert=server.pem | TCP:somehost:80" Is it possible to do the opposite? I.e. I have a…
Chris Snow
  • 23,813
  • 35
  • 144
  • 309
9
votes
0 answers

How to use socat proxy to intercept Unix domain socket sending ancillary data?

I have two programs, a server and a client. The server opens a file, writes data to it, and then send its file descriptor to the client over a unix domain socket. Everything works fine untill I introduce a socat proxy in between. socat -x -v…
Sahil Singh
  • 3,352
  • 39
  • 62
1
2 3
18 19