mirror of
https://github.com/nabbar/golib.git
synced 2025-10-05 07:46:56 +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:
@@ -35,22 +35,28 @@ import (
|
||||
"strings"
|
||||
|
||||
libptc "github.com/nabbar/golib/network/protocol"
|
||||
libsiz "github.com/nabbar/golib/size"
|
||||
libsck "github.com/nabbar/golib/socket"
|
||||
sckclt "github.com/nabbar/golib/socket/client/tcp"
|
||||
sckclu "github.com/nabbar/golib/socket/client/udp"
|
||||
sckclx "github.com/nabbar/golib/socket/client/unix"
|
||||
sckgrm "github.com/nabbar/golib/socket/client/unixgram"
|
||||
)
|
||||
|
||||
func New(proto libptc.NetworkProtocol, sizeBufferRead int32, address string) (libsck.Client, error) {
|
||||
func New(proto libptc.NetworkProtocol, sizeBufferRead libsiz.Size, address string) (libsck.Client, error) {
|
||||
switch proto {
|
||||
case libptc.NetworkUnix:
|
||||
if strings.EqualFold(runtime.GOOS, "linux") {
|
||||
return sckclx.New(sizeBufferRead, address), nil
|
||||
}
|
||||
case libptc.NetworkUnixGram:
|
||||
if strings.EqualFold(runtime.GOOS, "linux") {
|
||||
return sckgrm.New(sizeBufferRead, address), nil
|
||||
}
|
||||
case libptc.NetworkTCP, libptc.NetworkTCP4, libptc.NetworkTCP6:
|
||||
return sckclt.New(sizeBufferRead, address)
|
||||
case libptc.NetworkUDP, libptc.NetworkUDP4, libptc.NetworkUDP6:
|
||||
return sckclu.New(address)
|
||||
return sckclu.New(sizeBufferRead, address)
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("invalid client protocol")
|
||||
|
Reference in New Issue
Block a user