Skip to content

Instantly share code, notes, and snippets.

@ljjjustin
Last active April 1, 2025 15:17
Show Gist options
  • Save ljjjustin/585e817d1d7ce4eb75b87076e5b7aa7e to your computer and use it in GitHub Desktop.
Save ljjjustin/585e817d1d7ce4eb75b87076e5b7aa7e to your computer and use it in GitHub Desktop.

Revisions

  1. ljjjustin revised this gist Jun 21, 2017. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions socat-tcp-to-unix-socket.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    #!/bin/bash

    if [ $# -ne 2 ]; then
    echo "usage: $0 <listen port> <unix socket file>"
    exit
    fi

    PORT=$1
    SOCK=$2

    socat -d -d -d -lf ns-socat.log TCP-LISTEN:${PORT},reuseaddr,fork UNIX-CLIENT:${SOCK}
  2. ljjjustin created this gist Jun 21, 2017.
    12 changes: 12 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/bin/bash

    if [ $# -ne 3 ]; then
    echo "usage: $0 <unix socket file> <host> <listen port>"
    exit
    fi

    SOCK=$1
    HOST=$2
    PORT=$3

    socat -d -d -d -lf socat.log UNIX-LISTEN:${SOCK},reuseaddr,fork TCP:${HOST}:${PORT}