socat: Show incoming connections

14,215

By old habit I am just used to grouping arguments together like -dddd for more verbose debugging, but when I actually tried what the manpage said (-d -d) it worked just fine. For logging connections, just do:

socat -d -d tcp4-listen:9000 tcp4-listen:9001
Share:
14,215

Related videos on Youtube

Niklas B.
Author by

Niklas B.

We are hiring! https://stackoverflow.com/jobs/companies/cashlink-technologies-gmbh

Updated on September 18, 2022

Comments

  • Niklas B.
    Niklas B. over 1 year

    I am slightly going mad. Even if I call socat like this:

    socat -vvvv tcp4-listen:9000 tcp4-listen:9001
    

    it works perfectly, but doesn't inform me about incoming TCP connections! Is there an additional verbosity option that makes socat show this information, something like

    Connection from XYZ
    

    Can't be such a special function, or can it?

  • Mattias Ahnberg
    Mattias Ahnberg over 12 years
    ps; in your example the connection isn't "established" until something has connected to both port 9000 and 9001, so the output is printed upon both parties being connected. Just so you don't test only connections to one port and think it fails because it doesn't print anything. :P
  • Niklas B.
    Niklas B. over 12 years
    In this case I am interested in connections to both sides separately (or in fact only the lefthand listen part). Thanks for your answer, I'll accept this if nobody can provide a better solution (no offense, but this doesn't quite serve my use case).
  • Mattias Ahnberg
    Mattias Ahnberg over 12 years
    I gave it some more thought and came up with a very simple solution, so I replaced my old suggestion. If someone is interested they can look at the old edits. :P Hope this is good enough for your use case!
  • fche
    fche over 9 years
    ... but socat -d -d is a bit too wordy. It would be nice to have an option to log only one line per connection.