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:
nabbar
2024-01-28 08:20:05 +01:00
parent db0a79e2e7
commit c66a00917a
51 changed files with 2114 additions and 648 deletions

View File

@@ -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")