I tried implementing a UNIX socket handler (L58) in Go  in the following file. Would you consider this OK, valid, or correct?

The `.sock` file is cleaned up on `ctx.Done()`. I kind of achieved my goal. I have to add a pre-cleanup in case of an ungraceful shutdown. However, in case of a canceled context, it works right now

https://forgejo.lukasrotermund.de/lrotermund/libre-activity-tracker/src/branch/wip-tracker-and-socket/internal/tracker/socket_server.go

#go #golang #UnixSocket

Cookie monster!

I love how simple UNIX sockets are! All you have to do is add a listener to a file handle and send random bytes as data to the socket file, e.g. via `echo "hello world" | socat - UNIX-CONNECT:/tmp/myproject1000/mysocket.sock`.

Playing around with it is so much fun  

#UnixSocket #go #golang

Are there standardized responses for UNIX socket connections? For example, `OK\n` or `ERROR\n` for unknown commands? Or is it totally up to the implementation?

#unix #UnixSocket #linux

@lukasrotermund

AFAIK you can do anything you want with a socket connection. Push binary data over it. Invent your own protocol.

You can check the return value of the socket() call to see if it returned -1, and the errno(3) immediately after. But in-band communication is strictly up to you.

@lemgandi OK nice :) that is so cool!
@lukasrotermund @lemgandi you can also transmit credentials and file descriptors, which i think is cooler still