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?


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
  • 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 – Mattias Ahnberg Jan 26 '12 at 19:25
  • 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). – Niklas B. Jan 26 '12 at 19:42
  • 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! – Mattias Ahnberg Jan 27 '12 at 0:47
  • ... but socat -d -d is a bit too wordy. It would be nice to have an option to log only one line per connection. – fche Dec 29 '14 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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