netdb

package module
v0.0.0-...-0825d84 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2018 License: MIT Imports: 3 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

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. import "honnef.co/go/netdb"

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
⌂ 换网址