Unix domain socket (UDS) example by golang
Using go-task
$ task --list
* run-basic: run basic example
* run-readwrite: run readwrite example
* run-readwrite2: run readwrite2 example
* run-usinggob: run usinggob example
$ task [run-basic|run-readwrite|run-readwrite2|run-usinggob]
Open two terminals. the one is following:
$ cd cmd/basic/server
$ go run .
and another terminal is following:
$ cd cmd/basic/client
$ go run .
Open two terminals. the one is following:
$ cd cmd/readwrite/server
$ go run .
and another terminal is following:
$ cd cmd/readwrite/client
$ go run .
Open two terminals. the one is following:
$ cd cmd/readwrite2/server
$ go run .
and another terminal is following:
$ cd cmd/readwrite2/client
$ go run .
Open two terminals. the one is following:
$ cd cmd/usinggob/server
$ go run .
and another terminal is following:
$ cd cmd/usinggob/client
$ go run .
use socat. install it if not exists.
$ sudo apt install -y socat
and launch server program then input following commands.
$ mv /tmp/echo.sock /tmp/echo.sock.original
$ socat -t100 -x -v UNIX-LISTEN:/tmp/echo.sock,mode=777,reuseaddr,fork UNIX-CONNECT:/tmp/echo.sock.original