Skip to content

Instantly share code, notes, and snippets.

@ljjjustin
Last active April 4, 2024 15:00
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.
socat-unix-socket-to-tcp.sh
#!/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}
#!/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}
@davidoram
Copy link

davidoram commented Apr 10, 2018

Thanks for sharing - helped me connect rails apps to dockerized postgres databases without changing config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment