package server import ( "net" "os" "git.loafle.net/commons_go/rpc/server" ) func NewServerHandler(addr string) *ServerHandlers { sh := &ServerHandlers{} sh.addr = addr return sh } type ServerHandlers struct { server.ServerHandlers addr string } func (sh *ServerHandlers) OnStart() { // no op } func (sh *ServerHandlers) OnStop() { // no op } func (sh *ServerHandlers) Listen() (net.Listener, error) { os.Remove(sh.addr) l, err := net.ListenUnix("unix", &net.UnixAddr{Name: sh.addr, Net: "unix"}) if nil == err { os.Chmod(sh.addr, 0777) } return l, err } func (sh *ServerHandlers) OnAccept(conn net.Conn) (net.Conn, error) { return conn, nil }