netutil

package
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPort

func CheckPort(protocol string, addr string) bool

CheckPort 检查端口是否被占用

func ConnCheck

func ConnCheck(conn net.Conn) error

func DiscoverDNS

func DiscoverDNS(service, proto string, address string) ([]*net.SRV, error)

DiscoverDNS ...

func GetLocalIP

func GetLocalIP() string

func GetPort

func GetPort(addrOrNet interface{}) (int, error)

GetPort returns the port of an endpoint address.

func Listen

func Listen(address string, opts ...SockOpt) (_ net.Listener, err error)

func ListenPacket

func ListenPacket(address string, opts ...SockOpt) (_ net.PacketConn, err error)

func MustGetPort

func MustGetPort(addrOrNet interface{}) int

func NewTCPSocket

func NewTCPSocket(addr string, tlsConfig *tls.Config) (net.Listener, error)

NewTCPSocket creates a TCP socket listener with the specified address and the specified tls configuration. If tlsConfig is set, will encapsulate the TCP listener inside a TLS one.

Types

type SockOpt

type SockOpt func(opts *sockOpts) error

SockOpt sets up socket file's creating option

func WithChmod

func WithChmod(mask os.FileMode) SockOpt

WithChmod modifies socket file's access mode

func WithChown

func WithChown(uid, gid int) SockOpt

WithChown modifies the socket file's uid and gid

func WithNetCfg

func WithNetCfg(fn func(lc *net.ListenConfig)) SockOpt

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL