server/ipc/server_handlers_unix.go
crusader ab60b6ccda ing
2017-10-27 17:53:26 +09:00

21 lines
327 B
Go

package ipc
import (
"net"
"os"
)
// Addr is ex:/tmp/server.sock
func (sh *ServerHandlers) Listen() (l net.Listener, err error) {
os.Remove(sh.Addr)
l, err = net.ListenUnix("unix", &net.UnixAddr{Name: sh.Addr, Net: "unix"})
os.Chmod(sh.Addr, 0777)
return
}
func (sh *ServerHandlers) OnStop() {
os.Remove(sh.Addr)
}