socket

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package socket provides method for parsing addresses and opening listening sockets, supporting direct TCP/UNIX sockets and sockets provided by launchd/systemd for socket activation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(network, address string) (net.Listener, error)

Open a listening socket with the given network and address. Supports 'unix', 'tcp', 'launchd' and 'systemd' as the network.

For 'tcp' sockets, the address must be a host and a port. The opened socket will be bound with SO_REUSEPORT.

For 'unix' sockets, the address must be a path. The socket file will be set to unlink on close automatically.

For 'launchd' sockets, the address must be the name of the socket from the plist file. Only one socket maybe configured in the plist for that name, multiple sockets per name (e.g. separate IPv4/IPv4 sockets) are not supported.

For 'systemd' sockets, the address must be the name of the socket. In the systemd unit file, the FileDescriptorName option must be set and needs to match the address string.

func ParseAddress

func ParseAddress(input string, skipResolve bool) (network, address, host string, err error)

ParseAddress parses a string representing a TCP address or UNIX socket for our backend target. The input can be or the form "HOST:PORT" for a TCP socket, "unix:PATH" for a UNIX socket, and "systemd:NAME" or "launchd:NAME" for a socket provided by launchd/systemd for socket activation.

func ParseAndOpen

func ParseAndOpen(address string) (net.Listener, error)

ParseAndOpen combines the functionality of the ParseAddress and Open methods.

func ParseHTTPAddress

func ParseHTTPAddress(input string) (https bool, address string)

ParseHTTPAddress parses a string representing a TCP address or HTTP/HTTPS address If the input is HTTP/HTTPS, return address will strip away the prefix Otherwise, return address will be same as input https is default to be true, unless http:// prefix is found

Types

This section is empty.

Jump to

Keyboard shortcuts

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