This commit is contained in:
crusader 2017-12-05 11:52:14 +09:00
parent 32230e44c8
commit 7e2813ad35
4 changed files with 36 additions and 26 deletions

View File

@ -5,7 +5,11 @@ import (
) )
func NewSocketBuilder(address string) csc.SocketBuilder { func NewSocketBuilder(address string) csc.SocketBuilder {
return newSocketBuilder(address) sb := &SocketBuilders{}
sb.Network = "tcp"
sb.Address = "localhost:50006"
return sb
} }
type SocketBuilders struct { type SocketBuilders struct {

View File

@ -2,6 +2,7 @@ package server
import ( import (
"fmt" "fmt"
"net"
"git.loafle.net/commons_go/logging" "git.loafle.net/commons_go/logging"
"git.loafle.net/overflow/overflow_discovery/discovery" "git.loafle.net/overflow/overflow_discovery/discovery"
@ -33,6 +34,11 @@ func (sh *ServerHandlers) Init(serverCTX server.ServerContext) error {
return nil return nil
} }
func (sh *ServerHandlers) Listen(serverCTX server.ServerContext) (net.Listener, error) {
return net.Listen("tcp", "localhost:50006")
}
func (sh *ServerHandlers) OnStart(serverCTX server.ServerContext) { func (sh *ServerHandlers) OnStart(serverCTX server.ServerContext) {
sh.ServerHandlers.OnStart(serverCTX) sh.ServerHandlers.OnStart(serverCTX)

View File

@ -1,17 +1,17 @@
package server package server
import ( // import (
"net" // "net"
"os" // "os"
"git.loafle.net/commons_go/server" // "git.loafle.net/commons_go/server"
) // )
func (sh *ServerHandlers) Listen(serverCTX server.ServerContext) (net.Listener, error) { // func (sh *ServerHandlers) Listen(serverCTX server.ServerContext) (net.Listener, error) {
os.Remove(sh.addr) // os.Remove(sh.addr)
l, err := net.ListenUnix("unix", &net.UnixAddr{Name: sh.addr, Net: "unix"}) // l, err := net.ListenUnix("unix", &net.UnixAddr{Name: sh.addr, Net: "unix"})
if nil == err { // if nil == err {
os.Chmod(sh.addr, 0777) // os.Chmod(sh.addr, 0777)
} // }
return l, err // return l, err
} // }

View File

@ -1,16 +1,16 @@
package server package server
import ( // import (
"net" // "net"
"git.loafle.net/commons_go/server" // "git.loafle.net/commons_go/server"
"gopkg.in/natefinch/npipe.v2" // "gopkg.in/natefinch/npipe.v2"
) // )
func (sh *ServerHandlers) Listen(serverCTX server.ServerContext) (net.Listener, error) { // func (sh *ServerHandlers) Listen(serverCTX server.ServerContext) (net.Listener, error) {
ln, err := npipe.Listen(`\\.\pipe\` + sh.addr) // ln, err := npipe.Listen(`\\.\pipe\` + sh.addr)
if err != nil { // if err != nil {
// handle error // // handle error
} // }
return ln, err // return ln, err
} // }