https://github.com/devlights/go-unix-domain-socket-example
Unix domain socket (UDS) examples by golang
https://github.com/devlights/go-unix-domain-socket-example
chromebook go golang linux socket uds unix-domain-socket
Last synced: 2 months ago
JSON representation
Unix domain socket (UDS) examples by golang
- Host: GitHub
- URL: https://github.com/devlights/go-unix-domain-socket-example
- Owner: devlights
- License: mit
- Created: 2020-08-22T20:38:37.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-07-28T03:04:10.000Z (almost 3 years ago)
- Last Synced: 2025-02-28T08:28:25.539Z (3 months ago)
- Topics: chromebook, go, golang, linux, socket, uds, unix-domain-socket
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 20
- Watchers: 3
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-unix-domain-socket-example
Unix domain socket (UDS) example by golang## How to Run
### Using [go-task](https://taskfile.dev/)
```sh
$ 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]
```### basic
Open two terminals. the one is following:
```sh
$ cd cmd/basic/server
$ go run .
```and another terminal is following:
```sh
$ cd cmd/basic/client
$ go run .
```### read & write per connection
Open two terminals. the one is following:
```sh
$ cd cmd/readwrite/server
$ go run .
```and another terminal is following:
```sh
$ cd cmd/readwrite/client
$ go run .
```### N read & write on one connection
Open two terminals. the one is following:
```sh
$ cd cmd/readwrite2/server
$ go run .
```and another terminal is following:
```sh
$ cd cmd/readwrite2/client
$ go run .
```### Using encoding/gob package
Open two terminals. the one is following:
```sh
$ cd cmd/usinggob/server
$ go run .
```and another terminal is following:
```sh
$ cd cmd/usinggob/client
$ go run .
```## Monitor a local unix domain socket
use socat. install it if not exists.
```sh
$ sudo apt install -y socat
```and launch server program then input following commands.
```sh
$ 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
```### REFERENCES
[Can I monitor a local unix domain socket like tcpdump?](https://superuser.com/questions/484671/can-i-monitor-a-local-unix-domain-socket-like-tcpdump)