2017-10-26 12:30:55 +00:00
|
|
|
package ipc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
2017-10-27 02:16:09 +00:00
|
|
|
"os"
|
2017-10-26 12:30:55 +00:00
|
|
|
)
|
|
|
|
|
2017-10-27 07:07:14 +00:00
|
|
|
// Addr is ex:/tmp/server.sock
|
2017-10-27 02:16:09 +00:00
|
|
|
func (sh *ServerHandlers) Listen() (l net.Listener, err error) {
|
2017-10-27 02:26:15 +00:00
|
|
|
os.Remove(sh.Addr)
|
2017-10-27 02:16:09 +00:00
|
|
|
l, err = net.ListenUnix("unix", &net.UnixAddr{Name: sh.Addr, Net: "unix"})
|
2017-10-26 12:30:55 +00:00
|
|
|
|
2017-10-27 02:21:27 +00:00
|
|
|
os.Chmod(sh.Addr, 0777)
|
2017-10-27 02:16:09 +00:00
|
|
|
|
|
|
|
return
|
2017-10-26 12:30:55 +00:00
|
|
|
}
|
2017-10-26 12:34:15 +00:00
|
|
|
|
2017-10-27 08:53:26 +00:00
|
|
|
func (sh *ServerHandlers) OnStop() {
|
2017-10-27 02:26:15 +00:00
|
|
|
os.Remove(sh.Addr)
|
2017-10-26 12:34:15 +00:00
|
|
|
}
|