mirror of
https://github.com/nabbar/golib.git
synced 2025-10-06 00:06:50 +08:00
Package Socket:
- fix tcp,udp,unix socket - add socket unixgram for session less unix socket - optmize process & code - add some standalone test for server / client (add example server config for rsyslog) Package Network/Protocol: - add unixgram protocol Package Errors: - fix bug in loop to prevent circular include
This commit is contained in:
@@ -41,15 +41,22 @@ import (
|
||||
scksrt "github.com/nabbar/golib/socket/server/tcp"
|
||||
scksru "github.com/nabbar/golib/socket/server/udp"
|
||||
scksrx "github.com/nabbar/golib/socket/server/unix"
|
||||
sckgrm "github.com/nabbar/golib/socket/server/unixgram"
|
||||
)
|
||||
|
||||
func New(handler libsck.Handler, proto libptc.NetworkProtocol, sizeBufferRead libsiz.Size, address string, perm os.FileMode) (libsck.Server, error) {
|
||||
func New(handler libsck.Handler, proto libptc.NetworkProtocol, sizeBufferRead libsiz.Size, address string, perm os.FileMode, gid int32) (libsck.Server, error) {
|
||||
switch proto {
|
||||
case libptc.NetworkUnix:
|
||||
if strings.EqualFold(runtime.GOOS, "linux") {
|
||||
s := scksrx.New(handler, sizeBufferRead)
|
||||
s.RegisterSocket(address, perm)
|
||||
return s, nil
|
||||
e := s.RegisterSocket(address, perm, gid)
|
||||
return s, e
|
||||
}
|
||||
case libptc.NetworkUnixGram:
|
||||
if strings.EqualFold(runtime.GOOS, "linux") {
|
||||
s := sckgrm.New(handler, sizeBufferRead)
|
||||
e := s.RegisterSocket(address, perm, gid)
|
||||
return s, e
|
||||
}
|
||||
case libptc.NetworkTCP, libptc.NetworkTCP4, libptc.NetworkTCP6:
|
||||
s := scksrt.New(handler, sizeBufferRead)
|
||||
|
Reference in New Issue
Block a user