netdb

package module
v0.0.0-...-e902e86 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 3 Imported by: 5

README

This package has been frozen and deprecated. It is of poor quality and should not be used. Consider evaluating alternatives, such as github.com/TheDiveO/netdb

netdb

Install

go get honnef.co/go/netdb

Documentation

Documentation can be found at godoc.org.

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

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

These variables get populated from /etc/protocols and /etc/services respectively.

Functions

This section is empty.

Types

type Protoent

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

func GetProtoByName

func GetProtoByName(name string) (protoent *Protoent)

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

func GetProtoByNumber

func GetProtoByNumber(num int) (protoent *Protoent)

GetProtoByNumber returns the Protoent for a given protocol number.

func (*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.

type Servent

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

func 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.

func 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.

func (*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.

Jump to

Keyboard shortcuts

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