XU XUv0.8.8
中文

API

#net

import: #net

counts: 87 fns, 49 methods, 19 types, 0 consts, 0 ifaces

IP/port parsing, TCP/UDP IPv4/IPv6 and Unix sockets on Unix; Windows TCP remains limited.

struct HostPort

XuAPI
pub struct HostPort {
    pub host string
    pub port string
}

Purpose

net — `net` correspondence. IP values are owning strings of raw bytes (len 4 = IPv4, len 16 = IPv6). Stream I/O covers TCP IPv4/IPv6 and Unix pathname sockets on Darwin/Linux. UDP IPv4/IPv6 and DNS-over-TCP live in sibling files; raw IP remains stubbed. fd-level dial/listen/accept/conn_* stay for net/http and net/smtp.

Parameters

host string
host
port string
port

new_host_port

XuAPI
pub fn new_host_port() HostPort

Purpose

Construct host port.

Parameters

none

Returns

HostPort — a value of this type

(HostPort) host

XuAPI
pub fn (hp HostPort) host() string

Purpose

Method on `HostPort`: host.

Parameters

hp HostPort
receiver HostPort (value receiver)

Returns

string — result string

(HostPort) port

XuAPI
pub fn (hp HostPort) port() string

Purpose

Method on `HostPort`: port.

Parameters

hp HostPort
receiver HostPort (value receiver)

Returns

string — result string

ipv4

XuAPI
pub fn ipv4(a int, b int, c int, d int) string

Purpose

Build an IPv4 address from four 0..255 octets (a 4-byte string).

Parameters

a int
octet 1, 0..255
b int
octet 2, 0..255
c int
octet 3, 0..255
d int
octet 4, 0..255

Returns

string — result string

parse_ip

XuAPI
pub fn parse_ip(s &string) string

Purpose

Parse as ip.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

string — result string

ip_string

XuAPI
pub fn ip_string(ip &string) string

Purpose

IP string.

Parameters

ip &string
ip (borrowed; caller keeps it; type &string)

Returns

string — result string

ip_is_unspecified

XuAPI
pub fn ip_is_unspecified(ip &string) bool

Purpose

Whether ip is unspecified.

Parameters

ip &string
ip (borrowed; caller keeps it; type &string)

Returns

bool — true or false

ip_is_loopback

XuAPI
pub fn ip_is_loopback(ip &string) bool

Purpose

Whether ip is loopback.

Parameters

ip &string
ip (borrowed; caller keeps it; type &string)

Returns

bool — true or false

ip_is_private

XuAPI
pub fn ip_is_private(ip &string) bool

Purpose

Whether ip is private.

Parameters

ip &string
ip (borrowed; caller keeps it; type &string)

Returns

bool — true or false

join_host_port

XuAPI
pub fn join_host_port(host &string, port &string) string

Purpose

Join host port.

Parameters

host &string
host (borrowed; caller keeps it; type &string)
port &string
port (borrowed; caller keeps it; type &string)

Returns

string — result string

(&mut HostPort) split

XuAPI
pub fn (hp &mut HostPort) split(hostport string) int

Purpose

Method on `&mut HostPort`: split on the separator. Throws on failure.

Parameters

hp &mut HostPort
receiver &mut HostPort (exclusive borrow)
hostport string
hostport (string)

Returns

int — a value of this type

struct Conn

XuAPI
pub struct Conn {
    pub network string
    pub laddr string
    pub raddr string
    pub read_deadline_ns int
    pub write_deadline_ns int
}

Purpose

TCP IPv4 runtime wrappers + Conn/Listener methods

Parameters

network string
field (string)
laddr string
field (string)
raddr string
field (string)
read_deadline_ns int
field (int)
write_deadline_ns int
field (int)

struct Listener

XuAPI
pub struct Listener {
    pub network string
    pub addr string
}

Purpose

Public struct `Listener`.

Parameters

network string
field (string)
addr string
address

dial

XuAPI
pub fn dial(addr string) int

Purpose

Dial a connection.

Parameters

addr string
address (string)

Returns

int — a value of this type

dial_ns

XuAPI
pub fn dial_ns(addr string, ns int) int

Purpose

dial_ns is the fd-level connect with an optional SO_SNDTIMEO bound. ns <= 0 means no extra timeout (same as dial). Throws on failure.

Parameters

addr string
address (string)
ns int
ns (int)

Returns

int — a value of this type

listen

XuAPI
pub fn listen(addr string) int

Purpose

Listen for connections. Throws on failure.

Parameters

addr string
address (string)

Returns

int — a value of this type

accept

XuAPI
pub fn accept(fd int) int

Purpose

Accept one connection. Throws on failure.

Parameters

fd int
file descriptor (int)

Returns

int — a value of this type

conn_close

XuAPI
pub fn conn_close(fd int) int

Purpose

Connection close. Throws on failure.

Parameters

fd int
file descriptor (int)

Returns

int — a value of this type

conn_write

XuAPI
pub fn conn_write(fd int, data &string) int

Purpose

Connection write. Throws on failure.

Parameters

fd int
file descriptor (int)
data &string
data (borrowed; caller keeps it; type &string)

Returns

int — a value of this type

conn_read

XuAPI
pub fn conn_read(fd int, max int) string

Purpose

Connection read. Throws on failure.

Parameters

fd int
file descriptor (int)
max int
maximum (int)

Returns

string — result string

(&mut Conn) set_deadline

XuAPI
pub fn (c &mut Conn) set_deadline(t_ns int) int

Purpose

Conn.SetDeadline / SetReadDeadline / SetWriteDeadline. t_ns is absolute now_ns; 0 clears. Remaining time is applied as SO_RCVTIMEO/SO_SNDTIMEO before the next read/write so an in-flight syscall can return; 0 does not clear an already-armed kernel timeout until the next I/O path that sees t_ns==0 (set_deadline(0) does).

Parameters

c &mut Conn
receiver &mut Conn (exclusive borrow)
t_ns int
t_ns (int)

Returns

int — a value of this type

(&mut Conn) set_read_deadline

XuAPI
pub fn (c &mut Conn) set_read_deadline(t_ns int) int

Purpose

Method on `&mut Conn`: set read deadline.

Parameters

c &mut Conn
receiver &mut Conn (exclusive borrow)
t_ns int
t_ns (int)

Returns

int — a value of this type

(&mut Conn) set_write_deadline

XuAPI
pub fn (c &mut Conn) set_write_deadline(t_ns int) int

Purpose

Method on `&mut Conn`: set write deadline.

Parameters

c &mut Conn
receiver &mut Conn (exclusive borrow)
t_ns int
t_ns (int)

Returns

int — a value of this type

(&Conn) read

XuAPI
pub fn (c &Conn) read(max int) string

Purpose

Method on `&Conn`: read up to max bytes. Throws on failure.

Parameters

c &Conn
receiver &Conn (borrow)
max int
maximum (int)

Returns

string — result string

(&Conn) write

XuAPI
pub fn (c &Conn) write(data &string) int

Purpose

Method on `&Conn`: write data and return the byte count. Throws on failure.

Parameters

c &Conn
receiver &Conn (borrow)
data &string
data (borrowed; caller keeps it; type &string)

Returns

int — bytes written

(&mut Conn) close

XuAPI
pub fn (c &mut Conn) close() int

Purpose

Method on `&mut Conn`: close the resource. Throws on failure.

Parameters

c &mut Conn
receiver &mut Conn (exclusive borrow)

Returns

int — a value of this type

(Conn) local_addr

XuAPI
pub fn (c Conn) local_addr() string

Purpose

Method on `Conn`: local address.

Parameters

c Conn
receiver Conn (value receiver)

Returns

string — result string

(Conn) remote_addr

XuAPI
pub fn (c Conn) remote_addr() string

Purpose

Method on `Conn`: remote address.

Parameters

c Conn
receiver Conn (value receiver)

Returns

string — result string

(Listener) accept

XuAPI
pub fn (l Listener) accept() Conn

Purpose

Method on `Listener`: accept one connection. Throws on failure.

Parameters

l Listener
receiver Listener (value receiver)

Returns

Conn — a value of this type

(&mut Listener) close

XuAPI
pub fn (l &mut Listener) close() int

Purpose

Method on `&mut Listener`: close the resource. Throws on failure.

Parameters

l &mut Listener
receiver &mut Listener (exclusive borrow)

Returns

int — a value of this type

(Listener) addr

XuAPI
pub fn (l Listener) addr() string

Purpose

Method on `Listener`: address.

Parameters

l Listener
receiver Listener (value receiver)

Returns

string — result string

file_conn

XuAPI
pub fn file_conn(fd int) Conn

Purpose

File connection. Throws on failure.

Parameters

fd int
file descriptor (int)

Returns

Conn — a value of this type

file_listener

XuAPI
pub fn file_listener(fd int) Listener

Purpose

File listener. Throws on failure.

Parameters

fd int
file descriptor (int)

Returns

Listener — a value of this type

closed_conn

XuAPI
pub fn closed_conn() Conn

Purpose

Closed connection.

Parameters

none

Returns

Conn — a value of this type

(&Conn) is_closed

XuAPI
pub fn (c &Conn) is_closed() bool

Purpose

Method on `&Conn`: whether it is closed.

Parameters

c &Conn
receiver &Conn (borrow)

Returns

bool — true or false

(&Conn) descriptor

XuAPI
pub fn (c &Conn) descriptor() int

Purpose

Borrowed raw descriptor; platform adapters must not create a second owner. Throws on failure.

Parameters

c &Conn
receiver &Conn (borrow)

Returns

int — a value of this type

struct TCPAddr

XuAPI
pub struct TCPAddr {
    pub ip string
    pub port int
    pub zone string
}

Purpose

Addr types ( TCPAddr / UDPAddr / IPAddr / UnixAddr) plus SplitHostPort as a value-returning helper. IP fields are raw-byte strings.

Parameters

ip string
field (string)
port int
port
zone string
field (string)

struct UDPAddr

XuAPI
pub struct UDPAddr {
    pub ip string
    pub port int
    pub zone string
}

Purpose

Public struct `UDPAddr`.

Parameters

ip string
field (string)
port int
port
zone string
field (string)

struct IPAddr

XuAPI
pub struct IPAddr {
    pub ip string
    pub zone string
}

Purpose

Public struct `IPAddr`.

Parameters

ip string
field (string)
zone string
field (string)

struct UnixAddr

XuAPI
pub struct UnixAddr {
    pub name string
    pub network string
}

Purpose

Public struct `UnixAddr`.

Parameters

name string
name
network string
field (string)

new_tcp_addr

XuAPI
pub fn new_tcp_addr() TCPAddr

Purpose

Construct tcp addr.

Parameters

none

Returns

TCPAddr — a value of this type

new_udp_addr

XuAPI
pub fn new_udp_addr() UDPAddr

Purpose

Construct udp addr.

Parameters

none

Returns

UDPAddr — a value of this type

new_ip_addr

XuAPI
pub fn new_ip_addr() IPAddr

Purpose

Construct ip addr.

Parameters

none

Returns

IPAddr — a value of this type

new_unix_addr

XuAPI
pub fn new_unix_addr() UnixAddr

Purpose

Construct unix addr.

Parameters

none

Returns

UnixAddr — a value of this type

(TCPAddr) network

XuAPI
pub fn (a TCPAddr) network() string

Purpose

Call `network` on `TCPAddr`.

Parameters

a TCPAddr
receiver TCPAddr (value receiver)

Returns

string — result string

(UDPAddr) network

XuAPI
pub fn (a UDPAddr) network() string

Purpose

Call `network` on `UDPAddr`.

Parameters

a UDPAddr
receiver UDPAddr (value receiver)

Returns

string — result string

(IPAddr) network

XuAPI
pub fn (a IPAddr) network() string

Purpose

Call `network` on `IPAddr`.

Parameters

a IPAddr
receiver IPAddr (value receiver)

Returns

string — result string

(UnixAddr) network

XuAPI
pub fn (a UnixAddr) network() string

Purpose

Call `network` on `UnixAddr`.

Parameters

a UnixAddr
receiver UnixAddr (value receiver)

Returns

string — result string

(TCPAddr) to_string

XuAPI
pub fn (a TCPAddr) to_string() string

Purpose

Method on `TCPAddr`: convert to string.

Parameters

a TCPAddr
receiver TCPAddr (value receiver)

Returns

string — result string

(&UDPAddr) clone

XuAPI
pub fn (a &UDPAddr) clone() UDPAddr

Purpose

Method on `&UDPAddr`: copy into a new independent string.

Parameters

a &UDPAddr
receiver &UDPAddr (borrow)

Returns

UDPAddr — a value of this type

(UDPAddr) to_string

XuAPI
pub fn (a UDPAddr) to_string() string

Purpose

Method on `UDPAddr`: convert to string.

Parameters

a UDPAddr
receiver UDPAddr (value receiver)

Returns

string — result string

(IPAddr) to_string

XuAPI
pub fn (a IPAddr) to_string() string

Purpose

Method on `IPAddr`: convert to string.

Parameters

a IPAddr
receiver IPAddr (value receiver)

Returns

string — result string

(UnixAddr) to_string

XuAPI
pub fn (a UnixAddr) to_string() string

Purpose

Method on `UnixAddr`: convert to string.

Parameters

a UnixAddr
receiver UnixAddr (value receiver)

Returns

string — result string

split_host_port

XuAPI
pub fn split_host_port(hostport string) HostPort

Purpose

Split host port. Throws on failure.

Parameters

hostport string
hostport (string)

Returns

HostPort — a value of this type

resolve_tcp_addr

XuAPI
pub fn resolve_tcp_addr(network string, address string) TCPAddr

Purpose

Resolve TCP address. Throws on failure.

Parameters

network string
network (string)
address string
address (string)

Returns

TCPAddr — a value of this type

resolve_udp_addr

XuAPI
pub fn resolve_udp_addr(network string, address string) UDPAddr

Purpose

Resolve UDP address. Throws on failure.

Parameters

network string
network (string)
address string
address (string)

Returns

UDPAddr — a value of this type

resolve_ip_addr

XuAPI
pub fn resolve_ip_addr(network string, address string) IPAddr

Purpose

Resolve IP address. Throws on failure.

Parameters

network string
network (string)
address string
address (string)

Returns

IPAddr — a value of this type

resolve_unix_addr

XuAPI
pub fn resolve_unix_addr(network string, address string) UnixAddr

Purpose

Resolve unix address. Throws on failure.

Parameters

network string
network (string)
address string
address (string)

Returns

UnixAddr — a value of this type

struct Dialer

XuAPI
pub struct Dialer {
    pub timeout_ns int
    pub dual_stack bool
    pub local_ip string
    pub local_port int
}

Purpose

Dialer / ListenConfig and -shaped Dial/Listen (network, address). Context is for Dial/Listen ( DialContext / ListenConfig.Listen), not for Conn.Read/Write — those use SetDeadline like. The fd-level dial(addr)/listen(addr) in mod.xu stay for http/smtp.

Parameters

timeout_ns int
timeout_ns is a relative connect bound (SO_SNDTIMEO). 0 means no extra bound; context.deadline_ns still applies. dual_stack local_ip / local_port are stored for API shape and ignored by the stream dialer; UDP callers pass explicit local addresses.
dual_stack bool
field (bool)
local_ip string
field (string)
local_port int
field (int)

struct ListenConfig

XuAPI
pub struct ListenConfig {
    pub reuse bool
}

Purpose

Public struct `ListenConfig`.

Parameters

reuse bool
field (bool)

new_dialer

XuAPI
pub fn new_dialer() Dialer

Purpose

Construct dialer.

Parameters

none

Returns

Dialer — a value of this type

new_listen_config

XuAPI
pub fn new_listen_config() ListenConfig

Purpose

Construct listen config.

Parameters

none

Returns

ListenConfig — a value of this type

dial_tcp

XuAPI
pub fn dial_tcp(network string, laddr TCPAddr, raddr TCPAddr) Conn

Purpose

Dial TCP. Throws on failure.

Parameters

network string
network (string)
laddr TCPAddr
laddr (TCPAddr)
raddr TCPAddr
raddr (TCPAddr)

Returns

Conn — a value of this type

listen_tcp

XuAPI
pub fn listen_tcp(network string, laddr TCPAddr) Listener

Purpose

Listen TCP. Throws on failure.

Parameters

network string
network (string)
laddr TCPAddr
laddr (TCPAddr)

Returns

Listener — a value of this type

dial_to

XuAPI
pub fn dial_to(network string, address string) Conn

Purpose

Dial to. Throws on failure.

Parameters

network string
network (string)
address string
address (string)

Returns

Conn — a value of this type

listen_on

XuAPI
pub fn listen_on(network string, address string) Listener

Purpose

Listen on. Throws on failure.

Parameters

network string
network (string)
address string
address (string)

Returns

Listener — a value of this type

dial_context

XuAPI
pub fn dial_context(ctx &context.Context, network string, address string) Conn

Purpose

dial_context is net.DialContext.

Parameters

ctx &context.Context
ctx (borrowed; caller keeps it; type &context.Context)
network string
network (string)
address string
address (string)

Returns

Conn — a value of this type

(Dialer) dial

XuAPI
pub fn (d Dialer) dial(network string, address string) Conn

Purpose

Method on `Dialer`: dial a connection. Throws on failure.

Parameters

d Dialer
receiver Dialer (value receiver)
network string
network (string)
address string
address (string)

Returns

Conn — a value of this type

(Dialer) dial_context

XuAPI
pub fn (d Dialer) dial_context(ctx &context.Context, network string, address string) Conn

Purpose

Method on `Dialer`: dial context. Throws on failure.

Parameters

d Dialer
receiver Dialer (value receiver)
ctx &context.Context
ctx (borrowed; caller keeps it; type &context.Context)
network string
network (string)
address string
address (string)

Returns

Conn — a value of this type

dial_timeout

XuAPI
pub fn dial_timeout(network string, address string, timeout_ns int) Conn

Purpose

Dial timeout. Throws on failure.

Parameters

network string
network (string)
address string
address (string)
timeout_ns int
timeout in nanoseconds (int)

Returns

Conn — a value of this type

(ListenConfig) listen

XuAPI
pub fn (c ListenConfig) listen(ctx &context.Context, network string, address string) Listener

Purpose

listen is ListenConfig.Listen(ctx, network, address). Throws on failure.

Parameters

c ListenConfig
receiver ListenConfig (value receiver)
ctx &context.Context
ctx (borrowed; caller keeps it; type &context.Context)
network string
network (string)
address string
address (string)

Returns

Listener — a value of this type

listen_packet

XuAPI
pub fn listen_packet(network string, address string) PacketConn

Purpose

Listen packet. Throws on failure.

Parameters

network string
network (string)
address string
address (string)

Returns

PacketConn — a value of this type

struct Interface

XuAPI
pub struct Interface {
    pub index int
    pub mtu int
    pub name string
    pub hardware_addr string
    pub flags int
}

Purpose

Public struct `Interface`.

Parameters

index int
field (int)
mtu int
field (int)
name string
name
hardware_addr string
field (string)
flags int
field (int)

new_interface

XuAPI
pub fn new_interface() Interface

Purpose

Construct interface.

Parameters

none

Returns

Interface — a value of this type

flags_string

XuAPI
pub fn flags_string(f int) string

Purpose

Flags string.

Parameters

f int
callback or format string (int)

Returns

string — result string

(Interface) addrs

XuAPI
pub fn (ifi Interface) addrs() []string

Purpose

Call `addrs` on `Interface`. Throws on failure.

Parameters

ifi Interface
receiver Interface (value receiver)

Returns

[]string — slice result

interfaces

XuAPI
pub fn interfaces() []Interface

Purpose

Interfaces. Throws on failure.

Parameters

none

Returns

[]Interface — slice result

interface_addrs

XuAPI
pub fn interface_addrs() []string

Purpose

Interface addrs. Throws on failure.

Parameters

none

Returns

[]string — slice result

interface_by_name

XuAPI
pub fn interface_by_name(name string) Interface

Purpose

Interface by name. Throws on failure.

Parameters

name string
name (string)

Returns

Interface — a value of this type

interface_by_index

XuAPI
pub fn interface_by_index(index int) Interface

Purpose

Interface by index. Throws on failure.

Parameters

index int
index (int)

Returns

Interface — a value of this type

struct IPNet

XuAPI
pub struct IPNet {
    pub ip string
    pub mask string
}

Purpose

Public struct `IPNet`.

Parameters

ip string
field (string)
mask string
field (string)

struct CIDR

XuAPI
pub struct CIDR {
    pub ip string
    pub ipnet IPNet
}

Purpose

Public struct `CIDR`.

Parameters

ip string
field (string)
ipnet IPNet
field (IPNet)

ipv4_zero

XuAPI
pub fn ipv4_zero() string

Purpose

IPv4 zero.

Parameters

none

Returns

string — result string

ipv4_bcast

XuAPI
pub fn ipv4_bcast() string

Purpose

IPv4 bcast.

Parameters

none

Returns

string — result string

ipv4_allsys

XuAPI
pub fn ipv4_allsys() string

Purpose

IPv4 allsys.

Parameters

none

Returns

string — result string

ipv4_allrouter

XuAPI
pub fn ipv4_allrouter() string

Purpose

IPv4 allrouter.

Parameters

none

Returns

string — result string

ipv6_zero

XuAPI
pub fn ipv6_zero() string

Purpose

IPv6 zero.

Parameters

none

Returns

string — result string

ipv6_unspecified

XuAPI
pub fn ipv6_unspecified() string

Purpose

IPv6 unspecified.

Parameters

none

Returns

string — result string

ipv6_loopback

XuAPI
pub fn ipv6_loopback() string

Purpose

IPv6 loopback.

Parameters

none

Returns

string — result string

ipv6_interface_local_all_nodes

XuAPI
pub fn ipv6_interface_local_all_nodes() string

Purpose

IPv6 interface local all nodes.

Parameters

none

Returns

string — result string

ipv4_mask

XuAPI
pub fn ipv4_mask(a int, b int, c int, d int) string

Purpose

IPv4 mask.

Parameters

a int
value (int)
b int
b (int)
c int
byte or character code (int)
d int
d (int)

Returns

string — result string

cidr_mask

XuAPI
pub fn cidr_mask(ones int, bits int) string

Purpose

Cidr mask.

Parameters

ones int
ones (int)
bits int
bit count (int)

Returns

string — result string

ip_to4

XuAPI
pub fn ip_to4(ip &string) string

Purpose

IP to4.

Parameters

ip &string
ip (borrowed; caller keeps it; type &string)

Returns

string — result string

ip_to16

XuAPI
pub fn ip_to16(ip &string) string

Purpose

IP to16.

Parameters

ip &string
ip (borrowed; caller keeps it; type &string)

Returns

string — result string

ip_equal

XuAPI
pub fn ip_equal(a &string, b &string) bool

Purpose

IP equal.

Parameters

a &string
value (borrowed; caller keeps it; type &string)
b &string
b (borrowed; caller keeps it; type &string)

Returns

bool — true or false

ip_mask

XuAPI
pub fn ip_mask(ip &string, mask &string) string

Purpose

IP mask.

Parameters

ip &string
ip (borrowed; caller keeps it; type &string)
mask &string
mask (borrowed; caller keeps it; type &string)

Returns

string — result string

ip_default_mask

XuAPI
pub fn ip_default_mask(ip &string) string

Purpose

IP default mask.

Parameters

ip &string
ip (borrowed; caller keeps it; type &string)

Returns

string — result string

ip_mask_size

XuAPI
pub fn ip_mask_size(mask &string) int

Purpose

IP mask size.

Parameters

mask &string
mask (borrowed; caller keeps it; type &string)

Returns

int — a value of this type

ip_mask_bits

XuAPI
pub fn ip_mask_bits(mask &string) int

Purpose

IP mask bits.

Parameters

mask &string
mask (borrowed; caller keeps it; type &string)

Returns

int — a value of this type

ip_mask_string

XuAPI
pub fn ip_mask_string(mask &string) string

Purpose

IP mask string.

Parameters

mask &string
mask (borrowed; caller keeps it; type &string)

Returns

string — result string

(IPNet) network

XuAPI
pub fn (n IPNet) network() string

Purpose

Call `network` on `IPNet`.

Parameters

n IPNet
receiver IPNet (value receiver)

Returns

string — result string

(IPNet) contains

XuAPI
pub fn (n IPNet) contains(ip &string) bool

Purpose

Method on `IPNet`: report whether the input contains the given piece.

Parameters

n IPNet
receiver IPNet (value receiver)
ip &string
ip (borrowed; caller keeps it; type &string)

Returns

bool — true or false

(IPNet) to_string

XuAPI
pub fn (n IPNet) to_string() string

Purpose

Method on `IPNet`: convert to string.

Parameters

n IPNet
receiver IPNet (value receiver)

Returns

string — result string

parse_cidr

XuAPI
pub fn parse_cidr(s &string) CIDR

Purpose

Parse as cidr. Throws on failure.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

CIDR — a value of this type

ip_is_multicast

XuAPI
pub fn ip_is_multicast(ip &string) bool

Purpose

Whether ip is multicast.

Parameters

ip &string
ip (borrowed; caller keeps it; type &string)

Returns

bool — true or false

ip_is_interface_local_multicast

XuAPI
pub fn ip_is_interface_local_multicast(ip &string) bool

Purpose

Whether ip is interface_local_multicast.

Parameters

ip &string
ip (borrowed; caller keeps it; type &string)

Returns

bool — true or false

ip_is_global_unicast

XuAPI
pub fn ip_is_global_unicast(ip &string) bool

Purpose

Whether ip is global_unicast.

Parameters

ip &string
ip (borrowed; caller keeps it; type &string)

Returns

bool — true or false

dial_ip

XuAPI
pub fn dial_ip(network string, laddr IPAddr, raddr IPAddr) Conn

Purpose

Raw IP sockets ( IPConn). ResolveIPAddr works; DialIP/ListenIP wait on SOCK_RAW runtime support. Throws on failure.

Parameters

network string
network (string)
laddr IPAddr
laddr (IPAddr)
raddr IPAddr
raddr (IPAddr)

Returns

Conn — a value of this type

listen_ip

XuAPI
pub fn listen_ip(network string, laddr IPAddr) PacketConn

Purpose

Listen IP. Throws on failure.

Parameters

network string
network (string)
laddr IPAddr
laddr (IPAddr)

Returns

PacketConn — a value of this type

struct MX

XuAPI
pub struct MX {
    pub host string
    pub pref int
}

Purpose

Name lookup ( net/lookup.): numeric / localhost / hosts / DNS-over-TCP.

Parameters

host string
host
pref int
field (int)

struct NS

XuAPI
pub struct NS {
    pub host string
}

Purpose

Public struct `NS`.

Parameters

host string
host

struct SRV

XuAPI
pub struct SRV {
    pub target string
    pub port int
    pub priority int
    pub weight int
}

Purpose

Public struct `SRV`.

Parameters

target string
field (string)
port int
port
priority int
field (int)
weight int
field (int)

lookup_host

XuAPI
pub fn lookup_host(host string) []string

Purpose

Lookup host. Throws on failure.

Parameters

host string
host (string)

Returns

[]string — slice result

lookup_ip

XuAPI
pub fn lookup_ip(host string) []string

Purpose

Lookup IP. Throws on failure.

Parameters

host string
host (string)

Returns

[]string — slice result

lookup_cname

XuAPI
pub fn lookup_cname(host string) string

Purpose

Lookup cname. Throws on failure.

Parameters

host string
host (string)

Returns

string — result string

lookup_mx

XuAPI
pub fn lookup_mx(name string) []MX

Purpose

Lookup mx.

Parameters

name string
name (string)

Returns

[]MX — slice result

lookup_ns

XuAPI
pub fn lookup_ns(name string) []NS

Purpose

Lookup ns.

Parameters

name string
name (string)

Returns

[]NS — slice result

lookup_txt

XuAPI
pub fn lookup_txt(name string) []string

Purpose

Lookup txt.

Parameters

name string
name (string)

Returns

[]string — slice result

lookup_srv

XuAPI
pub fn lookup_srv(service string, proto string, name string) []SRV

Purpose

Lookup srv. Throws on failure.

Parameters

service string
service (string)
proto string
proto (string)
name string
name (string)

Returns

[]SRV — slice result

lookup_addr

XuAPI
pub fn lookup_addr(addr string) []string

Purpose

Lookup address. Throws on failure.

Parameters

addr string
address (string)

Returns

[]string — slice result

hardware_addr_string

XuAPI
pub fn hardware_addr_string(a &string) string

Purpose

HardwareAddr ( net/mac.). Raw bytes as an owning string; parse_mac accepts MAC-48 / EUI-48 / EUI-64 / 20-octet InfiniBand forms.

Parameters

a &string
value (borrowed; caller keeps it; type &string)

Returns

string — result string

parse_mac

XuAPI
pub fn parse_mac(s &string) string

Purpose

Parse as mac. Throws on failure.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

string — result string

struct PipeConn

XuAPI
pub struct PipeConn {
    pub w chan string
    pub r chan string
    pub closed int
}

Purpose

In-memory full-duplex pipe ( net.Pipe). Ends are channel-backed PipeConn values, not socket fds.

Parameters

w chan string
writer or width
r chan string
rune (Unicode code point)
closed int
field (int)

struct PipePair

XuAPI
pub struct PipePair {
    pub c1 PipeConn
    pub c2 PipeConn
}

Purpose

Public struct `PipePair`.

Parameters

c1 PipeConn
field (PipeConn)
c2 PipeConn
field (PipeConn)

pipe

XuAPI
pub fn pipe() PipePair

Purpose

pipe; returns PipePair.

Parameters

none

Returns

PipePair — a value of this type

(PipeConn) read

XuAPI
pub fn (c PipeConn) read() string

Purpose

Method on `PipeConn`: read up to max bytes. Throws on failure.

Parameters

c PipeConn
receiver PipeConn (value receiver)

Returns

string — result string

(PipeConn) write

XuAPI
pub fn (c PipeConn) write(data string) int

Purpose

Method on `PipeConn`: write data and return the byte count. Throws on failure.

Parameters

c PipeConn
receiver PipeConn (value receiver)
data string
data (string)

Returns

int — bytes written

(&mut PipeConn) close

XuAPI
pub fn (c &mut PipeConn) close() int

Purpose

Method on `&mut PipeConn`: close the resource.

Parameters

c &mut PipeConn
receiver &mut PipeConn (exclusive borrow)

Returns

int — a value of this type

(PipeConn) local_addr

XuAPI
pub fn (c PipeConn) local_addr() string

Purpose

Method on `PipeConn`: local address.

Parameters

c PipeConn
receiver PipeConn (value receiver)

Returns

string — result string

(PipeConn) remote_addr

XuAPI
pub fn (c PipeConn) remote_addr() string

Purpose

Method on `PipeConn`: remote address.

Parameters

c PipeConn
receiver PipeConn (value receiver)

Returns

string — result string

(PipeConn) network

XuAPI
pub fn (c PipeConn) network() string

Purpose

Call `network` on `PipeConn`.

Parameters

c PipeConn
receiver PipeConn (value receiver)

Returns

string — result string

lookup_port

XuAPI
pub fn lookup_port(network string, service string) int

Purpose

Lookup port. Throws on failure.

Parameters

network string
network (string)
service string
service (string)

Returns

int — a value of this type

lookup_protocol

XuAPI
pub fn lookup_protocol(name string) int

Purpose

Lookup protocol. Throws on failure.

Parameters

name string
name (string)

Returns

int — a value of this type

(&Conn) read_result

XuAPI
pub fn (c &Conn) read_result(n int) io.ReadResult

Purpose

Method on `&Conn`: read result.

Parameters

c &Conn
receiver &Conn (borrow)
n int
count, length, or limit (int)

Returns

io.ReadResult — a value of this type

(&Conn) write_result

XuAPI
pub fn (c &Conn) write_result(data string) io.WriteResult

Purpose

Method on `&Conn`: write result.

Parameters

c &Conn
receiver &Conn (borrow)
data string
data (string)

Returns

io.WriteResult — a value of this type

(&Conn) read_n

XuAPI
pub fn (c &Conn) read_n(n int) string

Purpose

io stream adapters preserve the existing per-connection deadline behavior. Throws on failure.

Parameters

c &Conn
receiver &Conn (borrow)
n int
count, length, or limit (int)

Returns

string — result string

(&Conn) write_str

XuAPI
pub fn (c &Conn) write_str(data string) int

Purpose

Method on `&Conn`: write a string. Throws on failure.

Parameters

c &Conn
receiver &Conn (borrow)
data string
data (string)

Returns

int — a value of this type

struct PacketConn

XuAPI
pub struct PacketConn {
    pub network string
    pub laddr string
    pub raddr string
}

Purpose

UDP types ( UDPConn / PacketConn). Datagram I/O is IPv4; socket/bind

Parameters

network string
field (string)
laddr string
field (string)
raddr string
field (string)

struct UDPPacket

XuAPI
pub struct UDPPacket {
    pub addr UDPAddr
    pub data string
}

Purpose

Public struct `UDPPacket`.

Parameters

addr UDPAddr
address
data string
data

(PacketConn) local_addr

XuAPI
pub fn (c PacketConn) local_addr() string

Purpose

Method on `PacketConn`: local address.

Parameters

c PacketConn
receiver PacketConn (value receiver)

Returns

string — result string

(PacketConn) remote_addr

XuAPI
pub fn (c PacketConn) remote_addr() string

Purpose

Method on `PacketConn`: remote address.

Parameters

c PacketConn
receiver PacketConn (value receiver)

Returns

string — result string

(&PacketConn) read

XuAPI
pub fn (c &PacketConn) read(max int) string

Purpose

Connected packet I/O uses socket recv/send so the Windows path reaches Winsock rather than the file-handle WriteFile/ReadFile helpers. Throws on failure.

Parameters

c &PacketConn
receiver &PacketConn (borrow)
max int
maximum (int)

Returns

string — result string

(&PacketConn) write

XuAPI
pub fn (c &PacketConn) write(data &string) int

Purpose

Method on `&PacketConn`: write data and return the byte count. Throws on failure.

Parameters

c &PacketConn
receiver &PacketConn (borrow)
data &string
data (borrowed; caller keeps it; type &string)

Returns

int — bytes written

(PacketConn) read_from

XuAPI
pub fn (c PacketConn) read_from(max int) UDPPacket

Purpose

Method on `PacketConn`: read from. Throws on failure.

Parameters

c PacketConn
receiver PacketConn (value receiver)
max int
maximum (int)

Returns

UDPPacket — a value of this type

(PacketConn) write_to

XuAPI
pub fn (c PacketConn) write_to(data &string, addr &UDPAddr) int

Purpose

Method on `PacketConn`: write to. Throws on failure.

Parameters

c PacketConn
receiver PacketConn (value receiver)
data &string
data (borrowed; caller keeps it; type &string)
addr &UDPAddr
address (borrowed; caller keeps it; type &UDPAddr)

Returns

int — a value of this type

(&mut PacketConn) close

XuAPI
pub fn (c &mut PacketConn) close() int

Purpose

Method on `&mut PacketConn`: close the resource. Throws on failure.

Parameters

c &mut PacketConn
receiver &mut PacketConn (exclusive borrow)

Returns

int — a value of this type

dial_udp

XuAPI
pub fn dial_udp(network string, laddr UDPAddr, raddr UDPAddr) PacketConn

Purpose

Dial UDP. Throws on failure.

Parameters

network string
network (string)
laddr UDPAddr
laddr (UDPAddr)
raddr UDPAddr
raddr (UDPAddr)

Returns

PacketConn — a value of this type

listen_udp

XuAPI
pub fn listen_udp(network string, laddr UDPAddr) PacketConn

Purpose

Listen UDP. Throws on failure.

Parameters

network string
network (string)
laddr UDPAddr
laddr (UDPAddr)

Returns

PacketConn — a value of this type

dial_unix

XuAPI
pub fn dial_unix(network string, laddr UnixAddr, raddr UnixAddr) Conn

Purpose

Dial unix. Throws on failure.

Parameters

network string
network (string)
laddr UnixAddr
laddr (UnixAddr)
raddr UnixAddr
raddr (UnixAddr)

Returns

Conn — a value of this type

listen_unix

XuAPI
pub fn listen_unix(network string, laddr UnixAddr) Listener

Purpose

Listen unix. Throws on failure.

Parameters

network string
network (string)
laddr UnixAddr
laddr (UnixAddr)

Returns

Listener — a value of this type