Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

netdb

v1.82.14
modernc.org/libc/honnef.co/go/netdb

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

12 matches

Top ↑

Package netdb provides a Go interface for the protoent and servent structures as defined in netdb.h

A pure Go implementation is used by parsing /etc/protocols and /etc/services

All return values are pointers that point to the entries in the original list of protocols and services. Manipulating the entries would affect the entire program.

Variables

Protocols (2 declarations)

var (
	Protocols []*Protoent
	Services  []*Servent
)

These variables get populated from /etc/protocols and /etc/services respectively, on the first call to GetProtoByNumber, GetProtoByName, GetServByName or GetServByPort.

Types

Protoent

type Protoent struct {
	Name    string
	Aliases []string
	Number  int
}

GetProtoByName

func GetProtoByName(name string) (protoent *Protoent)

GetProtoByName returns the Protoent whose name or any of its aliases matches the argument.

GetProtoByNumber

func GetProtoByNumber(num int) (protoent *Protoent)

GetProtoByNumber returns the Protoent for a given protocol number.

Protoent.Equal

func (this *Protoent) Equal(other *Protoent) bool

Equal checks if two Protoents are the same, which is the case if their protocol numbers are identical or when both Protoents are nil.

Servent

type Servent struct {
	Name     string
	Aliases  []string
	Port     int
	Protocol *Protoent
}

GetServByName

func GetServByName(name string, protocol *Protoent) (servent *Servent)

GetServByName returns the Servent for a given service name or alias and protocol. If the protocol is nil, the first service matching the service name is returned.

GetServByPort

func GetServByPort(port int, protocol *Protoent) *Servent

GetServByPort returns the Servent for a given port number and protocol. If the protocol is nil, the first service matching the port number is returned.

Servent.Equal

func (this *Servent) Equal(other *Servent) bool

Equal checks if two Servents are the same, which is the case if their port numbers and protocols are identical or when both Servents are nil.

Dependency graph