Search code examples
tcpipsocat

socat:get sender's IP address


I use following code to receive a connection:

socat TCP-LISTEN:4000,fork EXEC:"./myscrpit"

I need to have a sender's IP address in my script but SOCAT_PEERADDR is not set, what is the problem?


Solution

  • use pktinfo option for TCP-LISTEN so use following code:

    socat TCP-LISTEN:4000,pktinfo,fork EXEC:"./myscrpit