socat

What is socat?

Usage

socat -d -d - TCP4:www.example.com:80
A typical socat invocation

Addresses

~: socat2018/09/22 19:12:30 socat[15505] E exactly 2 addresses required (there are 0); use option "-h" for help
  • the address type, followed by a :
  • zero or more required address parameters separated by :
  • zero or more address options separated by ,
The anatomy of an address

Type

socat -d -d - TCP4:www.example.com:80

Parameters

Address Options

TCP:www.example.com:80,retry=5
TCP4-LISTEN:www.example.com:80,fork
Adress options have a many to 1 mapping with option groups.

Addresses, redux

socat -u STDIN STDOUT
$ socat -u STDIN STDOUT2018/10/14 14:18:15 socat[22736] N using stdin for reading2018/10/14 14:18:15 socat[22736] N using stdout for writing
...
$ socat STDIN STDOUT2018/10/14 14:19:48 socat[22739] N using stdin for reading and writing2018/10/14 14:19:48 socat[22739] N using stdout for reading and writing

Single Address Specification and Dual Addresses

socat -d -d - TCP4:www.example.com:80
Two Single Address Specifications
socat -d -d   READLINE\!\!OPEN:file.txt,creat,trunc   SYSTEM:'read stdin; echo $stdin'

Address options versus socat options

The Lifecycle of a socat instance

Examples

Why use socat when you can use netcat

A War Story

socat -d -d TCP-LISTEN:8004 TCP:10.2.7.21:8004

Conclusion

--

--

--

@copyconstruct on Twitter. views expressed on this blog are solely mine, not those of present or past employers.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

My journey with Harmony

Sensitive Data Exposure : My First Bug in H1

4P Strategy: AI-based Solution Recommendation for Incident Management

Mobile application Development Methodology

Requirements are dangerous

Consume ANY HTTP service from Laravel: The good way

HTTP Clients with Laravel

BigQuery: Tell me your region, I will tell you your speed!

My Experience in Preparing for and Taking the AWS Developer Associate Exam

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cindy Sridharan

Cindy Sridharan

@copyconstruct on Twitter. views expressed on this blog are solely mine, not those of present or past employers.

More from Medium

Advancing communication on the edge

Security updates: Grafana and Log4j

What I wish I knew about app modernisation 10 years ago

Photo by <a href=”https://burst.shopify.com/@lightleaksin?utm_campaign=photo_credit&amp;utm_content=Browse+Free+HD+Images+of+A+Woman+Stands+At+The+Back+Of+A+Massive+White+Clock+Face&amp;utm_medium=referral&amp;utm_source=credit">Samantha Hurley</a> from <a href=”https://burst.shopify.com/light?utm_campaign=photo_credit&amp;utm_content=Browse+Free+HD+Images+of+A+Woman+Stands+At+The+Back+Of+A+Massive+White+Clock+Face&amp;utm_medium=referral&amp;utm_source=credit">Burst</a>

The Evolution of Auth