Compare commits
5 Commits
e3d183d234
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| ed674e41e1 | |||
| 04a644869e | |||
| 80121031f9 | |||
| 26a422d5ed | |||
| 416d45a1de |
@@ -1,6 +1,8 @@
|
||||
# Binaries for programs and plugins
|
||||
main
|
||||
netio
|
||||
make
|
||||
examples/*[^.v]
|
||||
*.exe
|
||||
*.exe~
|
||||
*.so
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
`netio` is a flexible networking library for V programming language.
|
||||
|
||||
Differences with the V standard library `net` module:
|
||||
This module provides the low-level wrappers around C APIs and supports
|
||||
any kind of sockets, socket options, address families and protocols.
|
||||
`netio.protocol` submodule provides access to the operatins system protocols database.
|
||||
|
||||
* Provides the low-level wrappers around C API.
|
||||
* Supports any kind of sockets, socket options, address families and protocols.
|
||||
`netio` is tested only on Linux, but should work on all POSIX-compliant operating
|
||||
systems. Microsoft Windows support is not planned yet.
|
||||
|
||||
The `netio.protocol` submodule provides access to the operatins system protocols database.
|
||||
See examples/ dir in source code repository for usage examples.
|
||||
|
||||
-376
@@ -1,376 +0,0 @@
|
||||
module netio
|
||||
|
||||
/*
|
||||
This file is generated by make.vsh, DO NOT EDIT.
|
||||
*/
|
||||
|
||||
pub const af_alg = AddrFamily(38)
|
||||
pub const af_appletalk = AddrFamily(5)
|
||||
pub const af_ash = AddrFamily(18)
|
||||
pub const af_atmpvc = AddrFamily(8)
|
||||
pub const af_atmsvc = AddrFamily(20)
|
||||
pub const af_ax25 = AddrFamily(3)
|
||||
pub const af_bluetooth = AddrFamily(31)
|
||||
pub const af_bridge = AddrFamily(7)
|
||||
pub const af_caif = AddrFamily(37)
|
||||
pub const af_can = AddrFamily(29)
|
||||
pub const af_decnet = AddrFamily(12)
|
||||
pub const af_econet = AddrFamily(19)
|
||||
pub const af_file = AddrFamily(1)
|
||||
pub const af_ib = AddrFamily(27)
|
||||
pub const af_ieee802154 = AddrFamily(36)
|
||||
pub const af_inet6 = AddrFamily(10)
|
||||
pub const af_inet = AddrFamily(2)
|
||||
pub const af_ipx = AddrFamily(4)
|
||||
pub const af_irda = AddrFamily(23)
|
||||
pub const af_isdn = AddrFamily(34)
|
||||
pub const af_iucv = AddrFamily(32)
|
||||
pub const af_kcm = AddrFamily(41)
|
||||
pub const af_key = AddrFamily(15)
|
||||
pub const af_llc = AddrFamily(26)
|
||||
pub const af_local = AddrFamily(1)
|
||||
pub const af_max = AddrFamily(46)
|
||||
pub const af_mctp = AddrFamily(45)
|
||||
pub const af_mpls = AddrFamily(28)
|
||||
pub const af_netbeui = AddrFamily(13)
|
||||
pub const af_netlink = AddrFamily(16)
|
||||
pub const af_netrom = AddrFamily(6)
|
||||
pub const af_nfc = AddrFamily(39)
|
||||
pub const af_packet = AddrFamily(17)
|
||||
pub const af_phonet = AddrFamily(35)
|
||||
pub const af_pppox = AddrFamily(24)
|
||||
pub const af_qipcrtr = AddrFamily(42)
|
||||
pub const af_rds = AddrFamily(21)
|
||||
pub const af_rose = AddrFamily(11)
|
||||
pub const af_route = AddrFamily(16)
|
||||
pub const af_rxrpc = AddrFamily(33)
|
||||
pub const af_security = AddrFamily(14)
|
||||
pub const af_smc = AddrFamily(43)
|
||||
pub const af_sna = AddrFamily(22)
|
||||
pub const af_tipc = AddrFamily(30)
|
||||
pub const af_unix = AddrFamily(1)
|
||||
pub const af_unspec = AddrFamily(0)
|
||||
pub const af_vsock = AddrFamily(40)
|
||||
pub const af_wanpipe = AddrFamily(25)
|
||||
pub const af_x25 = AddrFamily(9)
|
||||
pub const af_xdp = AddrFamily(44)
|
||||
pub const ai_addrconfig = AddrInfoFlag(32)
|
||||
pub const ai_all = AddrInfoFlag(16)
|
||||
pub const ai_canonname = AddrInfoFlag(2)
|
||||
pub const ai_numerichost = AddrInfoFlag(4)
|
||||
pub const ai_numericserv = AddrInfoFlag(1024)
|
||||
pub const ai_passive = AddrInfoFlag(1)
|
||||
pub const ai_v4mapped = AddrInfoFlag(8)
|
||||
pub const ipproto_ah = SocketLevel(51)
|
||||
pub const ipproto_beetph = SocketLevel(94)
|
||||
pub const ipproto_comp = SocketLevel(108)
|
||||
pub const ipproto_dccp = SocketLevel(33)
|
||||
pub const ipproto_dstopts = SocketLevel(60)
|
||||
pub const ipproto_egp = SocketLevel(8)
|
||||
pub const ipproto_encap = SocketLevel(98)
|
||||
pub const ipproto_esp = SocketLevel(50)
|
||||
pub const ipproto_ethernet = SocketLevel(143)
|
||||
pub const ipproto_fragment = SocketLevel(44)
|
||||
pub const ipproto_gre = SocketLevel(47)
|
||||
pub const ipproto_hopopts = SocketLevel(0)
|
||||
pub const ipproto_icmpv6 = SocketLevel(58)
|
||||
pub const ipproto_icmp = SocketLevel(1)
|
||||
pub const ipproto_idp = SocketLevel(22)
|
||||
pub const ipproto_igmp = SocketLevel(2)
|
||||
pub const ipproto_ipip = SocketLevel(4)
|
||||
pub const ipproto_ipv6 = SocketLevel(41)
|
||||
pub const ipproto_ip = SocketLevel(0)
|
||||
pub const ipproto_l2tp = SocketLevel(115)
|
||||
pub const ipproto_mh = SocketLevel(135)
|
||||
pub const ipproto_mpls = SocketLevel(137)
|
||||
pub const ipproto_mptcp = SocketLevel(262)
|
||||
pub const ipproto_mtp = SocketLevel(92)
|
||||
pub const ipproto_none = SocketLevel(59)
|
||||
pub const ipproto_pim = SocketLevel(103)
|
||||
pub const ipproto_pup = SocketLevel(12)
|
||||
pub const ipproto_raw = SocketLevel(255)
|
||||
pub const ipproto_routing = SocketLevel(43)
|
||||
pub const ipproto_rsvp = SocketLevel(46)
|
||||
pub const ipproto_sctp = SocketLevel(132)
|
||||
pub const ipproto_smc = SocketLevel(256)
|
||||
pub const ipproto_tcp = SocketLevel(6)
|
||||
pub const ipproto_tp = SocketLevel(29)
|
||||
pub const ipproto_udplite = SocketLevel(136)
|
||||
pub const ipproto_udp = SocketLevel(17)
|
||||
pub const ipv6_2292dstopts = SocketOption(4)
|
||||
pub const ipv6_2292hoplimit = SocketOption(8)
|
||||
pub const ipv6_2292hopopts = SocketOption(3)
|
||||
pub const ipv6_2292pktinfo = SocketOption(2)
|
||||
pub const ipv6_2292pktoptions = SocketOption(6)
|
||||
pub const ipv6_2292rthdr = SocketOption(5)
|
||||
pub const ipv6_addrform = SocketOption(1)
|
||||
pub const ipv6_addr_preferences = SocketOption(72)
|
||||
pub const ipv6_add_membership = SocketOption(20)
|
||||
pub const ipv6_authhdr = SocketOption(10)
|
||||
pub const ipv6_autoflowlabel = SocketOption(70)
|
||||
pub const ipv6_checksum = SocketOption(7)
|
||||
pub const ipv6_dontfrag = SocketOption(62)
|
||||
pub const ipv6_drop_membership = SocketOption(21)
|
||||
pub const ipv6_dstopts = SocketOption(59)
|
||||
pub const ipv6_freebind = SocketOption(78)
|
||||
pub const ipv6_hdrincl = SocketOption(36)
|
||||
pub const ipv6_hoplimit = SocketOption(52)
|
||||
pub const ipv6_hopopts = SocketOption(54)
|
||||
pub const ipv6_ipsec_policy = SocketOption(34)
|
||||
pub const ipv6_join_anycast = SocketOption(27)
|
||||
pub const ipv6_join_group = SocketOption(20)
|
||||
pub const ipv6_leave_anycast = SocketOption(28)
|
||||
pub const ipv6_leave_group = SocketOption(21)
|
||||
pub const ipv6_minhopcount = SocketOption(73)
|
||||
pub const ipv6_mtu = SocketOption(24)
|
||||
pub const ipv6_mtu_discover = SocketOption(23)
|
||||
pub const ipv6_multicast_all = SocketOption(29)
|
||||
pub const ipv6_multicast_hops = SocketOption(18)
|
||||
pub const ipv6_multicast_if = SocketOption(17)
|
||||
pub const ipv6_multicast_loop = SocketOption(19)
|
||||
pub const ipv6_nexthop = SocketOption(9)
|
||||
pub const ipv6_origdstaddr = SocketOption(74)
|
||||
pub const ipv6_pathmtu = SocketOption(61)
|
||||
pub const ipv6_pktinfo = SocketOption(50)
|
||||
pub const ipv6_pmtudisc_dont = SocketOption(0)
|
||||
pub const ipv6_pmtudisc_do = SocketOption(2)
|
||||
pub const ipv6_pmtudisc_interface = SocketOption(4)
|
||||
pub const ipv6_pmtudisc_omit = SocketOption(5)
|
||||
pub const ipv6_pmtudisc_probe = SocketOption(3)
|
||||
pub const ipv6_pmtudisc_want = SocketOption(1)
|
||||
pub const ipv6_recvdstopts = SocketOption(58)
|
||||
pub const ipv6_recverr = SocketOption(25)
|
||||
pub const ipv6_recverr_rfc4884 = SocketOption(31)
|
||||
pub const ipv6_recvfragsize = SocketOption(77)
|
||||
pub const ipv6_recvhoplimit = SocketOption(51)
|
||||
pub const ipv6_recvhopopts = SocketOption(53)
|
||||
pub const ipv6_recvorigdstaddr = SocketOption(74)
|
||||
pub const ipv6_recvpathmtu = SocketOption(60)
|
||||
pub const ipv6_recvpktinfo = SocketOption(49)
|
||||
pub const ipv6_recvrthdr = SocketOption(56)
|
||||
pub const ipv6_recvtclass = SocketOption(66)
|
||||
pub const ipv6_router_alert = SocketOption(22)
|
||||
pub const ipv6_router_alert_isolate = SocketOption(30)
|
||||
pub const ipv6_rthdrdstopts = SocketOption(55)
|
||||
pub const ipv6_rthdr = SocketOption(57)
|
||||
pub const ipv6_rthdr_loose = SocketOption(0)
|
||||
pub const ipv6_rthdr_strict = SocketOption(1)
|
||||
pub const ipv6_rthdr_type_0 = SocketOption(0)
|
||||
pub const ipv6_rxdstopts = SocketOption(59)
|
||||
pub const ipv6_rxhopopts = SocketOption(54)
|
||||
pub const ipv6_tclass = SocketOption(67)
|
||||
pub const ipv6_transparent = SocketOption(75)
|
||||
pub const ipv6_unicast_hops = SocketOption(16)
|
||||
pub const ipv6_unicast_if = SocketOption(76)
|
||||
pub const ipv6_v6only = SocketOption(26)
|
||||
pub const ipv6_xfrm_policy = SocketOption(35)
|
||||
pub const ip_add_membership = SocketOption(35)
|
||||
pub const ip_add_source_membership = SocketOption(39)
|
||||
pub const ip_bind_address_no_port = SocketOption(24)
|
||||
pub const ip_block_source = SocketOption(38)
|
||||
pub const ip_checksum = SocketOption(23)
|
||||
pub const ip_default_multicast_loop = SocketOption(1)
|
||||
pub const ip_default_multicast_ttl = SocketOption(1)
|
||||
pub const ip_drop_membership = SocketOption(36)
|
||||
pub const ip_drop_source_membership = SocketOption(40)
|
||||
pub const ip_freebind = SocketOption(15)
|
||||
pub const ip_hdrincl = SocketOption(3)
|
||||
pub const ip_ipsec_policy = SocketOption(16)
|
||||
pub const ip_local_port_range = SocketOption(51)
|
||||
pub const ip_max_memberships = SocketOption(20)
|
||||
pub const ip_minttl = SocketOption(21)
|
||||
pub const ip_msfilter = SocketOption(41)
|
||||
pub const ip_mtu = SocketOption(14)
|
||||
pub const ip_mtu_discover = SocketOption(10)
|
||||
pub const ip_multicast_all = SocketOption(49)
|
||||
pub const ip_multicast_if = SocketOption(32)
|
||||
pub const ip_multicast_loop = SocketOption(34)
|
||||
pub const ip_multicast_ttl = SocketOption(33)
|
||||
pub const ip_nodefrag = SocketOption(22)
|
||||
pub const ip_options = SocketOption(4)
|
||||
pub const ip_origdstaddr = SocketOption(20)
|
||||
pub const ip_passsec = SocketOption(18)
|
||||
pub const ip_pktinfo = SocketOption(8)
|
||||
pub const ip_pktoptions = SocketOption(9)
|
||||
pub const ip_pmtudisc = SocketOption(10)
|
||||
pub const ip_pmtudisc_dont = SocketOption(0)
|
||||
pub const ip_pmtudisc_do = SocketOption(2)
|
||||
pub const ip_pmtudisc_interface = SocketOption(4)
|
||||
pub const ip_pmtudisc_omit = SocketOption(5)
|
||||
pub const ip_pmtudisc_probe = SocketOption(3)
|
||||
pub const ip_pmtudisc_want = SocketOption(1)
|
||||
pub const ip_protocol = SocketOption(52)
|
||||
pub const ip_recverr = SocketOption(11)
|
||||
pub const ip_recverr_rfc4884 = SocketOption(26)
|
||||
pub const ip_recvfragsize = SocketOption(25)
|
||||
pub const ip_recvopts = SocketOption(6)
|
||||
pub const ip_recvorigdstaddr = SocketOption(20)
|
||||
pub const ip_recvretopts = SocketOption(7)
|
||||
pub const ip_recvtos = SocketOption(13)
|
||||
pub const ip_recvttl = SocketOption(12)
|
||||
pub const ip_retopts = SocketOption(7)
|
||||
pub const ip_router_alert = SocketOption(5)
|
||||
pub const ip_tos = SocketOption(1)
|
||||
pub const ip_transparent = SocketOption(19)
|
||||
pub const ip_ttl = SocketOption(2)
|
||||
pub const ip_unblock_source = SocketOption(37)
|
||||
pub const ip_unicast_if = SocketOption(50)
|
||||
pub const ip_xfrm_policy = SocketOption(17)
|
||||
pub const msg_batch = MsgFlag(262144)
|
||||
pub const msg_cmsg_cloexec = MsgFlag(1073741824)
|
||||
pub const msg_confirm = MsgFlag(2048)
|
||||
pub const msg_ctrunc = MsgFlag(8)
|
||||
pub const msg_dontroute = MsgFlag(4)
|
||||
pub const msg_dontwait = MsgFlag(64)
|
||||
pub const msg_eor = MsgFlag(128)
|
||||
pub const msg_errqueue = MsgFlag(8192)
|
||||
pub const msg_fastopen = MsgFlag(536870912)
|
||||
pub const msg_fin = MsgFlag(512)
|
||||
pub const msg_more = MsgFlag(32768)
|
||||
pub const msg_nosignal = MsgFlag(16384)
|
||||
pub const msg_oob = MsgFlag(1)
|
||||
pub const msg_peek = MsgFlag(2)
|
||||
pub const msg_proxy = MsgFlag(16)
|
||||
pub const msg_rst = MsgFlag(4096)
|
||||
pub const msg_sock_devmem = MsgFlag(33554432)
|
||||
pub const msg_syn = MsgFlag(1024)
|
||||
pub const msg_trunc = MsgFlag(32)
|
||||
pub const msg_waitall = MsgFlag(256)
|
||||
pub const msg_waitforone = MsgFlag(65536)
|
||||
pub const msg_zerocopy = MsgFlag(67108864)
|
||||
pub const ni_dgram = NameInfoFlag(16)
|
||||
pub const ni_maxhost = NameInfoFlag(1025)
|
||||
pub const ni_maxserv = NameInfoFlag(32)
|
||||
pub const ni_namereqd = NameInfoFlag(8)
|
||||
pub const ni_nofqdn = NameInfoFlag(4)
|
||||
pub const ni_numerichost = NameInfoFlag(1)
|
||||
pub const ni_numericserv = NameInfoFlag(2)
|
||||
pub const sock_cloexec = SocketType(524288)
|
||||
pub const sock_dccp = SocketType(6)
|
||||
pub const sock_dgram = SocketType(2)
|
||||
pub const sock_nonblock = SocketType(2048)
|
||||
pub const sock_packet = SocketType(10)
|
||||
pub const sock_raw = SocketType(3)
|
||||
pub const sock_rdm = SocketType(4)
|
||||
pub const sock_seqpacket = SocketType(5)
|
||||
pub const sock_stream = SocketType(1)
|
||||
pub const sol_aal = SocketLevel(265)
|
||||
pub const sol_alg = SocketLevel(279)
|
||||
pub const sol_atm = SocketLevel(264)
|
||||
pub const sol_bluetooth = SocketLevel(274)
|
||||
pub const sol_caif = SocketLevel(278)
|
||||
pub const sol_dccp = SocketLevel(269)
|
||||
pub const sol_decnet = SocketLevel(261)
|
||||
pub const sol_icmpv6 = SocketLevel(58)
|
||||
pub const sol_ipv6 = SocketLevel(41)
|
||||
pub const sol_ip = SocketLevel(0)
|
||||
pub const sol_irda = SocketLevel(266)
|
||||
pub const sol_iucv = SocketLevel(277)
|
||||
pub const sol_kcm = SocketLevel(281)
|
||||
pub const sol_llc = SocketLevel(268)
|
||||
pub const sol_mctp = SocketLevel(285)
|
||||
pub const sol_mptcp = SocketLevel(284)
|
||||
pub const sol_netbeui = SocketLevel(267)
|
||||
pub const sol_netlink = SocketLevel(270)
|
||||
pub const sol_nfc = SocketLevel(280)
|
||||
pub const sol_packet = SocketLevel(263)
|
||||
pub const sol_pnpipe = SocketLevel(275)
|
||||
pub const sol_pppol2tp = SocketLevel(273)
|
||||
pub const sol_raw = SocketLevel(255)
|
||||
pub const sol_rds = SocketLevel(276)
|
||||
pub const sol_rxrpc = SocketLevel(272)
|
||||
pub const sol_smc = SocketLevel(286)
|
||||
pub const sol_socket = SocketLevel(1)
|
||||
pub const sol_tipc = SocketLevel(271)
|
||||
pub const sol_tls = SocketLevel(282)
|
||||
pub const sol_vsock = SocketLevel(287)
|
||||
pub const sol_x25 = SocketLevel(262)
|
||||
pub const sol_xdp = SocketLevel(283)
|
||||
pub const so_acceptconn = SocketOption(30)
|
||||
pub const so_attach_bpf = SocketOption(50)
|
||||
pub const so_attach_filter = SocketOption(26)
|
||||
pub const so_attach_reuseport_cbpf = SocketOption(51)
|
||||
pub const so_attach_reuseport_ebpf = SocketOption(52)
|
||||
pub const so_bindtodevice = SocketOption(25)
|
||||
pub const so_bindtoifindex = SocketOption(62)
|
||||
pub const so_bpf_extensions = SocketOption(48)
|
||||
pub const so_broadcast = SocketOption(6)
|
||||
pub const so_bsdcompat = SocketOption(14)
|
||||
pub const so_buf_lock = SocketOption(72)
|
||||
pub const so_busy_poll = SocketOption(46)
|
||||
pub const so_busy_poll_budget = SocketOption(70)
|
||||
pub const so_cnx_advice = SocketOption(53)
|
||||
pub const so_cookie = SocketOption(57)
|
||||
pub const so_debug = SocketOption(1)
|
||||
pub const so_detach_bpf = SocketOption(27)
|
||||
pub const so_detach_filter = SocketOption(27)
|
||||
pub const so_detach_reuseport_bpf = SocketOption(68)
|
||||
pub const so_devmem_dmabuf = SocketOption(79)
|
||||
pub const so_devmem_dontneed = SocketOption(80)
|
||||
pub const so_devmem_linear = SocketOption(78)
|
||||
pub const so_domain = SocketOption(39)
|
||||
pub const so_dontroute = SocketOption(5)
|
||||
pub const so_error = SocketOption(4)
|
||||
pub const so_get_filter = SocketOption(26)
|
||||
pub const so_incoming_cpu = SocketOption(49)
|
||||
pub const so_incoming_napi_id = SocketOption(56)
|
||||
pub const so_inq = SocketOption(84)
|
||||
pub const so_keepalive = SocketOption(9)
|
||||
pub const so_linger = SocketOption(13)
|
||||
pub const so_lock_filter = SocketOption(44)
|
||||
pub const so_mark = SocketOption(36)
|
||||
pub const so_max_pacing_rate = SocketOption(47)
|
||||
pub const so_meminfo = SocketOption(55)
|
||||
pub const so_netns_cookie = SocketOption(71)
|
||||
pub const so_nofcs = SocketOption(43)
|
||||
pub const so_no_check = SocketOption(11)
|
||||
pub const so_oobinline = SocketOption(10)
|
||||
pub const so_passcred = SocketOption(16)
|
||||
pub const so_passpidfd = SocketOption(76)
|
||||
pub const so_passrights = SocketOption(83)
|
||||
pub const so_passsec = SocketOption(34)
|
||||
pub const so_peek_off = SocketOption(42)
|
||||
pub const so_peercred = SocketOption(17)
|
||||
pub const so_peergroups = SocketOption(59)
|
||||
pub const so_peername = SocketOption(28)
|
||||
pub const so_peerpidfd = SocketOption(77)
|
||||
pub const so_peersec = SocketOption(31)
|
||||
pub const so_prefer_busy_poll = SocketOption(69)
|
||||
pub const so_priority = SocketOption(12)
|
||||
pub const so_protocol = SocketOption(38)
|
||||
pub const so_rcvbufforce = SocketOption(33)
|
||||
pub const so_rcvbuf = SocketOption(8)
|
||||
pub const so_rcvlowat = SocketOption(18)
|
||||
pub const so_rcvmark = SocketOption(75)
|
||||
pub const so_rcvpriority = SocketOption(82)
|
||||
pub const so_rcvtimeo = SocketOption(20)
|
||||
pub const so_rcvtimeo_new = SocketOption(66)
|
||||
pub const so_rcvtimeo_old = SocketOption(20)
|
||||
pub const so_reserve_mem = SocketOption(73)
|
||||
pub const so_reuseaddr = SocketOption(2)
|
||||
pub const so_reuseport = SocketOption(15)
|
||||
pub const so_rxq_ovfl = SocketOption(40)
|
||||
pub const so_security_authentication = SocketOption(22)
|
||||
pub const so_security_encryption_network = SocketOption(24)
|
||||
pub const so_security_encryption_transport = SocketOption(23)
|
||||
pub const so_select_err_queue = SocketOption(45)
|
||||
pub const so_sndbufforce = SocketOption(32)
|
||||
pub const so_sndbuf = SocketOption(7)
|
||||
pub const so_sndlowat = SocketOption(19)
|
||||
pub const so_sndtimeo = SocketOption(21)
|
||||
pub const so_sndtimeo_new = SocketOption(67)
|
||||
pub const so_sndtimeo_old = SocketOption(21)
|
||||
pub const so_timestamping = SocketOption(37)
|
||||
pub const so_timestamping_new = SocketOption(65)
|
||||
pub const so_timestamping_old = SocketOption(37)
|
||||
pub const so_timestampns = SocketOption(35)
|
||||
pub const so_timestampns_new = SocketOption(64)
|
||||
pub const so_timestampns_old = SocketOption(35)
|
||||
pub const so_timestamp = SocketOption(29)
|
||||
pub const so_timestamp_new = SocketOption(63)
|
||||
pub const so_timestamp_old = SocketOption(29)
|
||||
pub const so_txrehash = SocketOption(74)
|
||||
pub const so_txtime = SocketOption(61)
|
||||
pub const so_type = SocketOption(3)
|
||||
pub const so_wifi_status = SocketOption(41)
|
||||
pub const so_zerocopy = SocketOption(60)
|
||||
@@ -1,7 +1,7 @@
|
||||
module netio
|
||||
|
||||
/*
|
||||
This file is generated by make.vsh, DO NOT EDIT.
|
||||
This file is generated by make.vsh, DO NOT EDIT.
|
||||
*/
|
||||
|
||||
pub const af_appletalk = AddrFamily(16)
|
||||
@@ -0,0 +1,376 @@
|
||||
module netio
|
||||
|
||||
/*
|
||||
This file is generated by make.vsh, DO NOT EDIT.
|
||||
*/
|
||||
|
||||
pub const af_alg = AddrFamily(38) // AF_ALG
|
||||
pub const af_appletalk = AddrFamily(5) // AF_APPLETALK
|
||||
pub const af_ash = AddrFamily(18) // AF_ASH
|
||||
pub const af_atmpvc = AddrFamily(8) // AF_ATMPVC
|
||||
pub const af_atmsvc = AddrFamily(20) // AF_ATMSVC
|
||||
pub const af_ax25 = AddrFamily(3) // AF_AX25
|
||||
pub const af_bluetooth = AddrFamily(31) // AF_BLUETOOTH
|
||||
pub const af_bridge = AddrFamily(7) // AF_BRIDGE
|
||||
pub const af_caif = AddrFamily(37) // AF_CAIF
|
||||
pub const af_can = AddrFamily(29) // AF_CAN
|
||||
pub const af_decnet = AddrFamily(12) // AF_DECNET
|
||||
pub const af_econet = AddrFamily(19) // AF_ECONET
|
||||
pub const af_file = AddrFamily(1) // AF_FILE
|
||||
pub const af_ib = AddrFamily(27) // AF_IB
|
||||
pub const af_ieee802154 = AddrFamily(36) // AF_IEEE802154
|
||||
pub const af_inet6 = AddrFamily(10) // AF_INET6
|
||||
pub const af_inet = AddrFamily(2) // AF_INET
|
||||
pub const af_ipx = AddrFamily(4) // AF_IPX
|
||||
pub const af_irda = AddrFamily(23) // AF_IRDA
|
||||
pub const af_isdn = AddrFamily(34) // AF_ISDN
|
||||
pub const af_iucv = AddrFamily(32) // AF_IUCV
|
||||
pub const af_kcm = AddrFamily(41) // AF_KCM
|
||||
pub const af_key = AddrFamily(15) // AF_KEY
|
||||
pub const af_llc = AddrFamily(26) // AF_LLC
|
||||
pub const af_local = AddrFamily(1) // AF_LOCAL
|
||||
pub const af_max = AddrFamily(46) // AF_MAX
|
||||
pub const af_mctp = AddrFamily(45) // AF_MCTP
|
||||
pub const af_mpls = AddrFamily(28) // AF_MPLS
|
||||
pub const af_netbeui = AddrFamily(13) // AF_NETBEUI
|
||||
pub const af_netlink = AddrFamily(16) // AF_NETLINK
|
||||
pub const af_netrom = AddrFamily(6) // AF_NETROM
|
||||
pub const af_nfc = AddrFamily(39) // AF_NFC
|
||||
pub const af_packet = AddrFamily(17) // AF_PACKET
|
||||
pub const af_phonet = AddrFamily(35) // AF_PHONET
|
||||
pub const af_pppox = AddrFamily(24) // AF_PPPOX
|
||||
pub const af_qipcrtr = AddrFamily(42) // AF_QIPCRTR
|
||||
pub const af_rds = AddrFamily(21) // AF_RDS
|
||||
pub const af_rose = AddrFamily(11) // AF_ROSE
|
||||
pub const af_route = AddrFamily(16) // AF_ROUTE
|
||||
pub const af_rxrpc = AddrFamily(33) // AF_RXRPC
|
||||
pub const af_security = AddrFamily(14) // AF_SECURITY
|
||||
pub const af_smc = AddrFamily(43) // AF_SMC
|
||||
pub const af_sna = AddrFamily(22) // AF_SNA
|
||||
pub const af_tipc = AddrFamily(30) // AF_TIPC
|
||||
pub const af_unix = AddrFamily(1) // AF_UNIX
|
||||
pub const af_unspec = AddrFamily(0) // AF_UNSPEC
|
||||
pub const af_vsock = AddrFamily(40) // AF_VSOCK
|
||||
pub const af_wanpipe = AddrFamily(25) // AF_WANPIPE
|
||||
pub const af_x25 = AddrFamily(9) // AF_X25
|
||||
pub const af_xdp = AddrFamily(44) // AF_XDP
|
||||
pub const ai_addrconfig = AddrInfoFlag(32) // AI_ADDRCONFIG
|
||||
pub const ai_all = AddrInfoFlag(16) // AI_ALL
|
||||
pub const ai_canonname = AddrInfoFlag(2) // AI_CANONNAME
|
||||
pub const ai_numerichost = AddrInfoFlag(4) // AI_NUMERICHOST
|
||||
pub const ai_numericserv = AddrInfoFlag(1024) // AI_NUMERICSERV
|
||||
pub const ai_passive = AddrInfoFlag(1) // AI_PASSIVE
|
||||
pub const ai_v4mapped = AddrInfoFlag(8) // AI_V4MAPPED
|
||||
pub const ipproto_ah = SocketLevel(51) // IPPROTO_AH
|
||||
pub const ipproto_beetph = SocketLevel(94) // IPPROTO_BEETPH
|
||||
pub const ipproto_comp = SocketLevel(108) // IPPROTO_COMP
|
||||
pub const ipproto_dccp = SocketLevel(33) // IPPROTO_DCCP
|
||||
pub const ipproto_dstopts = SocketLevel(60) // IPPROTO_DSTOPTS
|
||||
pub const ipproto_egp = SocketLevel(8) // IPPROTO_EGP
|
||||
pub const ipproto_encap = SocketLevel(98) // IPPROTO_ENCAP
|
||||
pub const ipproto_esp = SocketLevel(50) // IPPROTO_ESP
|
||||
pub const ipproto_ethernet = SocketLevel(143) // IPPROTO_ETHERNET
|
||||
pub const ipproto_fragment = SocketLevel(44) // IPPROTO_FRAGMENT
|
||||
pub const ipproto_gre = SocketLevel(47) // IPPROTO_GRE
|
||||
pub const ipproto_hopopts = SocketLevel(0) // IPPROTO_HOPOPTS
|
||||
pub const ipproto_icmpv6 = SocketLevel(58) // IPPROTO_ICMPV6
|
||||
pub const ipproto_icmp = SocketLevel(1) // IPPROTO_ICMP
|
||||
pub const ipproto_idp = SocketLevel(22) // IPPROTO_IDP
|
||||
pub const ipproto_igmp = SocketLevel(2) // IPPROTO_IGMP
|
||||
pub const ipproto_ipip = SocketLevel(4) // IPPROTO_IPIP
|
||||
pub const ipproto_ipv6 = SocketLevel(41) // IPPROTO_IPV6
|
||||
pub const ipproto_ip = SocketLevel(0) // IPPROTO_IP
|
||||
pub const ipproto_l2tp = SocketLevel(115) // IPPROTO_L2TP
|
||||
pub const ipproto_mh = SocketLevel(135) // IPPROTO_MH
|
||||
pub const ipproto_mpls = SocketLevel(137) // IPPROTO_MPLS
|
||||
pub const ipproto_mptcp = SocketLevel(262) // IPPROTO_MPTCP
|
||||
pub const ipproto_mtp = SocketLevel(92) // IPPROTO_MTP
|
||||
pub const ipproto_none = SocketLevel(59) // IPPROTO_NONE
|
||||
pub const ipproto_pim = SocketLevel(103) // IPPROTO_PIM
|
||||
pub const ipproto_pup = SocketLevel(12) // IPPROTO_PUP
|
||||
pub const ipproto_raw = SocketLevel(255) // IPPROTO_RAW
|
||||
pub const ipproto_routing = SocketLevel(43) // IPPROTO_ROUTING
|
||||
pub const ipproto_rsvp = SocketLevel(46) // IPPROTO_RSVP
|
||||
pub const ipproto_sctp = SocketLevel(132) // IPPROTO_SCTP
|
||||
pub const ipproto_smc = SocketLevel(256) // IPPROTO_SMC
|
||||
pub const ipproto_tcp = SocketLevel(6) // IPPROTO_TCP
|
||||
pub const ipproto_tp = SocketLevel(29) // IPPROTO_TP
|
||||
pub const ipproto_udplite = SocketLevel(136) // IPPROTO_UDPLITE
|
||||
pub const ipproto_udp = SocketLevel(17) // IPPROTO_UDP
|
||||
pub const ipv6_2292dstopts = SocketOption(4) // IPV6_2292DSTOPTS
|
||||
pub const ipv6_2292hoplimit = SocketOption(8) // IPV6_2292HOPLIMIT
|
||||
pub const ipv6_2292hopopts = SocketOption(3) // IPV6_2292HOPOPTS
|
||||
pub const ipv6_2292pktinfo = SocketOption(2) // IPV6_2292PKTINFO
|
||||
pub const ipv6_2292pktoptions = SocketOption(6) // IPV6_2292PKTOPTIONS
|
||||
pub const ipv6_2292rthdr = SocketOption(5) // IPV6_2292RTHDR
|
||||
pub const ipv6_addrform = SocketOption(1) // IPV6_ADDRFORM
|
||||
pub const ipv6_addr_preferences = SocketOption(72) // IPV6_ADDR_PREFERENCES
|
||||
pub const ipv6_add_membership = SocketOption(20) // IPV6_ADD_MEMBERSHIP
|
||||
pub const ipv6_authhdr = SocketOption(10) // IPV6_AUTHHDR
|
||||
pub const ipv6_autoflowlabel = SocketOption(70) // IPV6_AUTOFLOWLABEL
|
||||
pub const ipv6_checksum = SocketOption(7) // IPV6_CHECKSUM
|
||||
pub const ipv6_dontfrag = SocketOption(62) // IPV6_DONTFRAG
|
||||
pub const ipv6_drop_membership = SocketOption(21) // IPV6_DROP_MEMBERSHIP
|
||||
pub const ipv6_dstopts = SocketOption(59) // IPV6_DSTOPTS
|
||||
pub const ipv6_freebind = SocketOption(78) // IPV6_FREEBIND
|
||||
pub const ipv6_hdrincl = SocketOption(36) // IPV6_HDRINCL
|
||||
pub const ipv6_hoplimit = SocketOption(52) // IPV6_HOPLIMIT
|
||||
pub const ipv6_hopopts = SocketOption(54) // IPV6_HOPOPTS
|
||||
pub const ipv6_ipsec_policy = SocketOption(34) // IPV6_IPSEC_POLICY
|
||||
pub const ipv6_join_anycast = SocketOption(27) // IPV6_JOIN_ANYCAST
|
||||
pub const ipv6_join_group = SocketOption(20) // IPV6_JOIN_GROUP
|
||||
pub const ipv6_leave_anycast = SocketOption(28) // IPV6_LEAVE_ANYCAST
|
||||
pub const ipv6_leave_group = SocketOption(21) // IPV6_LEAVE_GROUP
|
||||
pub const ipv6_minhopcount = SocketOption(73) // IPV6_MINHOPCOUNT
|
||||
pub const ipv6_mtu = SocketOption(24) // IPV6_MTU
|
||||
pub const ipv6_mtu_discover = SocketOption(23) // IPV6_MTU_DISCOVER
|
||||
pub const ipv6_multicast_all = SocketOption(29) // IPV6_MULTICAST_ALL
|
||||
pub const ipv6_multicast_hops = SocketOption(18) // IPV6_MULTICAST_HOPS
|
||||
pub const ipv6_multicast_if = SocketOption(17) // IPV6_MULTICAST_IF
|
||||
pub const ipv6_multicast_loop = SocketOption(19) // IPV6_MULTICAST_LOOP
|
||||
pub const ipv6_nexthop = SocketOption(9) // IPV6_NEXTHOP
|
||||
pub const ipv6_origdstaddr = SocketOption(74) // IPV6_ORIGDSTADDR
|
||||
pub const ipv6_pathmtu = SocketOption(61) // IPV6_PATHMTU
|
||||
pub const ipv6_pktinfo = SocketOption(50) // IPV6_PKTINFO
|
||||
pub const ipv6_pmtudisc_dont = SocketOption(0) // IPV6_PMTUDISC_DONT
|
||||
pub const ipv6_pmtudisc_do = SocketOption(2) // IPV6_PMTUDISC_DO
|
||||
pub const ipv6_pmtudisc_interface = SocketOption(4) // IPV6_PMTUDISC_INTERFACE
|
||||
pub const ipv6_pmtudisc_omit = SocketOption(5) // IPV6_PMTUDISC_OMIT
|
||||
pub const ipv6_pmtudisc_probe = SocketOption(3) // IPV6_PMTUDISC_PROBE
|
||||
pub const ipv6_pmtudisc_want = SocketOption(1) // IPV6_PMTUDISC_WANT
|
||||
pub const ipv6_recvdstopts = SocketOption(58) // IPV6_RECVDSTOPTS
|
||||
pub const ipv6_recverr = SocketOption(25) // IPV6_RECVERR
|
||||
pub const ipv6_recverr_rfc4884 = SocketOption(31) // IPV6_RECVERR_RFC4884
|
||||
pub const ipv6_recvfragsize = SocketOption(77) // IPV6_RECVFRAGSIZE
|
||||
pub const ipv6_recvhoplimit = SocketOption(51) // IPV6_RECVHOPLIMIT
|
||||
pub const ipv6_recvhopopts = SocketOption(53) // IPV6_RECVHOPOPTS
|
||||
pub const ipv6_recvorigdstaddr = SocketOption(74) // IPV6_RECVORIGDSTADDR
|
||||
pub const ipv6_recvpathmtu = SocketOption(60) // IPV6_RECVPATHMTU
|
||||
pub const ipv6_recvpktinfo = SocketOption(49) // IPV6_RECVPKTINFO
|
||||
pub const ipv6_recvrthdr = SocketOption(56) // IPV6_RECVRTHDR
|
||||
pub const ipv6_recvtclass = SocketOption(66) // IPV6_RECVTCLASS
|
||||
pub const ipv6_router_alert = SocketOption(22) // IPV6_ROUTER_ALERT
|
||||
pub const ipv6_router_alert_isolate = SocketOption(30) // IPV6_ROUTER_ALERT_ISOLATE
|
||||
pub const ipv6_rthdrdstopts = SocketOption(55) // IPV6_RTHDRDSTOPTS
|
||||
pub const ipv6_rthdr = SocketOption(57) // IPV6_RTHDR
|
||||
pub const ipv6_rthdr_loose = SocketOption(0) // IPV6_RTHDR_LOOSE
|
||||
pub const ipv6_rthdr_strict = SocketOption(1) // IPV6_RTHDR_STRICT
|
||||
pub const ipv6_rthdr_type_0 = SocketOption(0) // IPV6_RTHDR_TYPE_0
|
||||
pub const ipv6_rxdstopts = SocketOption(59) // IPV6_RXDSTOPTS
|
||||
pub const ipv6_rxhopopts = SocketOption(54) // IPV6_RXHOPOPTS
|
||||
pub const ipv6_tclass = SocketOption(67) // IPV6_TCLASS
|
||||
pub const ipv6_transparent = SocketOption(75) // IPV6_TRANSPARENT
|
||||
pub const ipv6_unicast_hops = SocketOption(16) // IPV6_UNICAST_HOPS
|
||||
pub const ipv6_unicast_if = SocketOption(76) // IPV6_UNICAST_IF
|
||||
pub const ipv6_v6only = SocketOption(26) // IPV6_V6ONLY
|
||||
pub const ipv6_xfrm_policy = SocketOption(35) // IPV6_XFRM_POLICY
|
||||
pub const ip_add_membership = SocketOption(35) // IP_ADD_MEMBERSHIP
|
||||
pub const ip_add_source_membership = SocketOption(39) // IP_ADD_SOURCE_MEMBERSHIP
|
||||
pub const ip_bind_address_no_port = SocketOption(24) // IP_BIND_ADDRESS_NO_PORT
|
||||
pub const ip_block_source = SocketOption(38) // IP_BLOCK_SOURCE
|
||||
pub const ip_checksum = SocketOption(23) // IP_CHECKSUM
|
||||
pub const ip_default_multicast_loop = SocketOption(1) // IP_DEFAULT_MULTICAST_LOOP
|
||||
pub const ip_default_multicast_ttl = SocketOption(1) // IP_DEFAULT_MULTICAST_TTL
|
||||
pub const ip_drop_membership = SocketOption(36) // IP_DROP_MEMBERSHIP
|
||||
pub const ip_drop_source_membership = SocketOption(40) // IP_DROP_SOURCE_MEMBERSHIP
|
||||
pub const ip_freebind = SocketOption(15) // IP_FREEBIND
|
||||
pub const ip_hdrincl = SocketOption(3) // IP_HDRINCL
|
||||
pub const ip_ipsec_policy = SocketOption(16) // IP_IPSEC_POLICY
|
||||
pub const ip_local_port_range = SocketOption(51) // IP_LOCAL_PORT_RANGE
|
||||
pub const ip_max_memberships = SocketOption(20) // IP_MAX_MEMBERSHIPS
|
||||
pub const ip_minttl = SocketOption(21) // IP_MINTTL
|
||||
pub const ip_msfilter = SocketOption(41) // IP_MSFILTER
|
||||
pub const ip_mtu = SocketOption(14) // IP_MTU
|
||||
pub const ip_mtu_discover = SocketOption(10) // IP_MTU_DISCOVER
|
||||
pub const ip_multicast_all = SocketOption(49) // IP_MULTICAST_ALL
|
||||
pub const ip_multicast_if = SocketOption(32) // IP_MULTICAST_IF
|
||||
pub const ip_multicast_loop = SocketOption(34) // IP_MULTICAST_LOOP
|
||||
pub const ip_multicast_ttl = SocketOption(33) // IP_MULTICAST_TTL
|
||||
pub const ip_nodefrag = SocketOption(22) // IP_NODEFRAG
|
||||
pub const ip_options = SocketOption(4) // IP_OPTIONS
|
||||
pub const ip_origdstaddr = SocketOption(20) // IP_ORIGDSTADDR
|
||||
pub const ip_passsec = SocketOption(18) // IP_PASSSEC
|
||||
pub const ip_pktinfo = SocketOption(8) // IP_PKTINFO
|
||||
pub const ip_pktoptions = SocketOption(9) // IP_PKTOPTIONS
|
||||
pub const ip_pmtudisc = SocketOption(10) // IP_PMTUDISC
|
||||
pub const ip_pmtudisc_dont = SocketOption(0) // IP_PMTUDISC_DONT
|
||||
pub const ip_pmtudisc_do = SocketOption(2) // IP_PMTUDISC_DO
|
||||
pub const ip_pmtudisc_interface = SocketOption(4) // IP_PMTUDISC_INTERFACE
|
||||
pub const ip_pmtudisc_omit = SocketOption(5) // IP_PMTUDISC_OMIT
|
||||
pub const ip_pmtudisc_probe = SocketOption(3) // IP_PMTUDISC_PROBE
|
||||
pub const ip_pmtudisc_want = SocketOption(1) // IP_PMTUDISC_WANT
|
||||
pub const ip_protocol = SocketOption(52) // IP_PROTOCOL
|
||||
pub const ip_recverr = SocketOption(11) // IP_RECVERR
|
||||
pub const ip_recverr_rfc4884 = SocketOption(26) // IP_RECVERR_RFC4884
|
||||
pub const ip_recvfragsize = SocketOption(25) // IP_RECVFRAGSIZE
|
||||
pub const ip_recvopts = SocketOption(6) // IP_RECVOPTS
|
||||
pub const ip_recvorigdstaddr = SocketOption(20) // IP_RECVORIGDSTADDR
|
||||
pub const ip_recvretopts = SocketOption(7) // IP_RECVRETOPTS
|
||||
pub const ip_recvtos = SocketOption(13) // IP_RECVTOS
|
||||
pub const ip_recvttl = SocketOption(12) // IP_RECVTTL
|
||||
pub const ip_retopts = SocketOption(7) // IP_RETOPTS
|
||||
pub const ip_router_alert = SocketOption(5) // IP_ROUTER_ALERT
|
||||
pub const ip_tos = SocketOption(1) // IP_TOS
|
||||
pub const ip_transparent = SocketOption(19) // IP_TRANSPARENT
|
||||
pub const ip_ttl = SocketOption(2) // IP_TTL
|
||||
pub const ip_unblock_source = SocketOption(37) // IP_UNBLOCK_SOURCE
|
||||
pub const ip_unicast_if = SocketOption(50) // IP_UNICAST_IF
|
||||
pub const ip_xfrm_policy = SocketOption(17) // IP_XFRM_POLICY
|
||||
pub const msg_batch = MsgFlag(262144) // MSG_BATCH
|
||||
pub const msg_cmsg_cloexec = MsgFlag(1073741824) // MSG_CMSG_CLOEXEC
|
||||
pub const msg_confirm = MsgFlag(2048) // MSG_CONFIRM
|
||||
pub const msg_ctrunc = MsgFlag(8) // MSG_CTRUNC
|
||||
pub const msg_dontroute = MsgFlag(4) // MSG_DONTROUTE
|
||||
pub const msg_dontwait = MsgFlag(64) // MSG_DONTWAIT
|
||||
pub const msg_eor = MsgFlag(128) // MSG_EOR
|
||||
pub const msg_errqueue = MsgFlag(8192) // MSG_ERRQUEUE
|
||||
pub const msg_fastopen = MsgFlag(536870912) // MSG_FASTOPEN
|
||||
pub const msg_fin = MsgFlag(512) // MSG_FIN
|
||||
pub const msg_more = MsgFlag(32768) // MSG_MORE
|
||||
pub const msg_nosignal = MsgFlag(16384) // MSG_NOSIGNAL
|
||||
pub const msg_oob = MsgFlag(1) // MSG_OOB
|
||||
pub const msg_peek = MsgFlag(2) // MSG_PEEK
|
||||
pub const msg_proxy = MsgFlag(16) // MSG_PROXY
|
||||
pub const msg_rst = MsgFlag(4096) // MSG_RST
|
||||
pub const msg_sock_devmem = MsgFlag(33554432) // MSG_SOCK_DEVMEM
|
||||
pub const msg_syn = MsgFlag(1024) // MSG_SYN
|
||||
pub const msg_trunc = MsgFlag(32) // MSG_TRUNC
|
||||
pub const msg_waitall = MsgFlag(256) // MSG_WAITALL
|
||||
pub const msg_waitforone = MsgFlag(65536) // MSG_WAITFORONE
|
||||
pub const msg_zerocopy = MsgFlag(67108864) // MSG_ZEROCOPY
|
||||
pub const ni_dgram = NameInfoFlag(16) // NI_DGRAM
|
||||
pub const ni_maxhost = NameInfoFlag(1025) // NI_MAXHOST
|
||||
pub const ni_maxserv = NameInfoFlag(32) // NI_MAXSERV
|
||||
pub const ni_namereqd = NameInfoFlag(8) // NI_NAMEREQD
|
||||
pub const ni_nofqdn = NameInfoFlag(4) // NI_NOFQDN
|
||||
pub const ni_numerichost = NameInfoFlag(1) // NI_NUMERICHOST
|
||||
pub const ni_numericserv = NameInfoFlag(2) // NI_NUMERICSERV
|
||||
pub const sock_cloexec = SocketType(524288) // SOCK_CLOEXEC
|
||||
pub const sock_dccp = SocketType(6) // SOCK_DCCP
|
||||
pub const sock_dgram = SocketType(2) // SOCK_DGRAM
|
||||
pub const sock_nonblock = SocketType(2048) // SOCK_NONBLOCK
|
||||
pub const sock_packet = SocketType(10) // SOCK_PACKET
|
||||
pub const sock_raw = SocketType(3) // SOCK_RAW
|
||||
pub const sock_rdm = SocketType(4) // SOCK_RDM
|
||||
pub const sock_seqpacket = SocketType(5) // SOCK_SEQPACKET
|
||||
pub const sock_stream = SocketType(1) // SOCK_STREAM
|
||||
pub const sol_aal = SocketLevel(265) // SOL_AAL
|
||||
pub const sol_alg = SocketLevel(279) // SOL_ALG
|
||||
pub const sol_atm = SocketLevel(264) // SOL_ATM
|
||||
pub const sol_bluetooth = SocketLevel(274) // SOL_BLUETOOTH
|
||||
pub const sol_caif = SocketLevel(278) // SOL_CAIF
|
||||
pub const sol_dccp = SocketLevel(269) // SOL_DCCP
|
||||
pub const sol_decnet = SocketLevel(261) // SOL_DECNET
|
||||
pub const sol_icmpv6 = SocketLevel(58) // SOL_ICMPV6
|
||||
pub const sol_ipv6 = SocketLevel(41) // SOL_IPV6
|
||||
pub const sol_ip = SocketLevel(0) // SOL_IP
|
||||
pub const sol_irda = SocketLevel(266) // SOL_IRDA
|
||||
pub const sol_iucv = SocketLevel(277) // SOL_IUCV
|
||||
pub const sol_kcm = SocketLevel(281) // SOL_KCM
|
||||
pub const sol_llc = SocketLevel(268) // SOL_LLC
|
||||
pub const sol_mctp = SocketLevel(285) // SOL_MCTP
|
||||
pub const sol_mptcp = SocketLevel(284) // SOL_MPTCP
|
||||
pub const sol_netbeui = SocketLevel(267) // SOL_NETBEUI
|
||||
pub const sol_netlink = SocketLevel(270) // SOL_NETLINK
|
||||
pub const sol_nfc = SocketLevel(280) // SOL_NFC
|
||||
pub const sol_packet = SocketLevel(263) // SOL_PACKET
|
||||
pub const sol_pnpipe = SocketLevel(275) // SOL_PNPIPE
|
||||
pub const sol_pppol2tp = SocketLevel(273) // SOL_PPPOL2TP
|
||||
pub const sol_raw = SocketLevel(255) // SOL_RAW
|
||||
pub const sol_rds = SocketLevel(276) // SOL_RDS
|
||||
pub const sol_rxrpc = SocketLevel(272) // SOL_RXRPC
|
||||
pub const sol_smc = SocketLevel(286) // SOL_SMC
|
||||
pub const sol_socket = SocketLevel(1) // SOL_SOCKET
|
||||
pub const sol_tipc = SocketLevel(271) // SOL_TIPC
|
||||
pub const sol_tls = SocketLevel(282) // SOL_TLS
|
||||
pub const sol_vsock = SocketLevel(287) // SOL_VSOCK
|
||||
pub const sol_x25 = SocketLevel(262) // SOL_X25
|
||||
pub const sol_xdp = SocketLevel(283) // SOL_XDP
|
||||
pub const so_acceptconn = SocketOption(30) // SO_ACCEPTCONN
|
||||
pub const so_attach_bpf = SocketOption(50) // SO_ATTACH_BPF
|
||||
pub const so_attach_filter = SocketOption(26) // SO_ATTACH_FILTER
|
||||
pub const so_attach_reuseport_cbpf = SocketOption(51) // SO_ATTACH_REUSEPORT_CBPF
|
||||
pub const so_attach_reuseport_ebpf = SocketOption(52) // SO_ATTACH_REUSEPORT_EBPF
|
||||
pub const so_bindtodevice = SocketOption(25) // SO_BINDTODEVICE
|
||||
pub const so_bindtoifindex = SocketOption(62) // SO_BINDTOIFINDEX
|
||||
pub const so_bpf_extensions = SocketOption(48) // SO_BPF_EXTENSIONS
|
||||
pub const so_broadcast = SocketOption(6) // SO_BROADCAST
|
||||
pub const so_bsdcompat = SocketOption(14) // SO_BSDCOMPAT
|
||||
pub const so_buf_lock = SocketOption(72) // SO_BUF_LOCK
|
||||
pub const so_busy_poll = SocketOption(46) // SO_BUSY_POLL
|
||||
pub const so_busy_poll_budget = SocketOption(70) // SO_BUSY_POLL_BUDGET
|
||||
pub const so_cnx_advice = SocketOption(53) // SO_CNX_ADVICE
|
||||
pub const so_cookie = SocketOption(57) // SO_COOKIE
|
||||
pub const so_debug = SocketOption(1) // SO_DEBUG
|
||||
pub const so_detach_bpf = SocketOption(27) // SO_DETACH_BPF
|
||||
pub const so_detach_filter = SocketOption(27) // SO_DETACH_FILTER
|
||||
pub const so_detach_reuseport_bpf = SocketOption(68) // SO_DETACH_REUSEPORT_BPF
|
||||
pub const so_devmem_dmabuf = SocketOption(79) // SO_DEVMEM_DMABUF
|
||||
pub const so_devmem_dontneed = SocketOption(80) // SO_DEVMEM_DONTNEED
|
||||
pub const so_devmem_linear = SocketOption(78) // SO_DEVMEM_LINEAR
|
||||
pub const so_domain = SocketOption(39) // SO_DOMAIN
|
||||
pub const so_dontroute = SocketOption(5) // SO_DONTROUTE
|
||||
pub const so_error = SocketOption(4) // SO_ERROR
|
||||
pub const so_get_filter = SocketOption(26) // SO_GET_FILTER
|
||||
pub const so_incoming_cpu = SocketOption(49) // SO_INCOMING_CPU
|
||||
pub const so_incoming_napi_id = SocketOption(56) // SO_INCOMING_NAPI_ID
|
||||
pub const so_inq = SocketOption(84) // SO_INQ
|
||||
pub const so_keepalive = SocketOption(9) // SO_KEEPALIVE
|
||||
pub const so_linger = SocketOption(13) // SO_LINGER
|
||||
pub const so_lock_filter = SocketOption(44) // SO_LOCK_FILTER
|
||||
pub const so_mark = SocketOption(36) // SO_MARK
|
||||
pub const so_max_pacing_rate = SocketOption(47) // SO_MAX_PACING_RATE
|
||||
pub const so_meminfo = SocketOption(55) // SO_MEMINFO
|
||||
pub const so_netns_cookie = SocketOption(71) // SO_NETNS_COOKIE
|
||||
pub const so_nofcs = SocketOption(43) // SO_NOFCS
|
||||
pub const so_no_check = SocketOption(11) // SO_NO_CHECK
|
||||
pub const so_oobinline = SocketOption(10) // SO_OOBINLINE
|
||||
pub const so_passcred = SocketOption(16) // SO_PASSCRED
|
||||
pub const so_passpidfd = SocketOption(76) // SO_PASSPIDFD
|
||||
pub const so_passrights = SocketOption(83) // SO_PASSRIGHTS
|
||||
pub const so_passsec = SocketOption(34) // SO_PASSSEC
|
||||
pub const so_peek_off = SocketOption(42) // SO_PEEK_OFF
|
||||
pub const so_peercred = SocketOption(17) // SO_PEERCRED
|
||||
pub const so_peergroups = SocketOption(59) // SO_PEERGROUPS
|
||||
pub const so_peername = SocketOption(28) // SO_PEERNAME
|
||||
pub const so_peerpidfd = SocketOption(77) // SO_PEERPIDFD
|
||||
pub const so_peersec = SocketOption(31) // SO_PEERSEC
|
||||
pub const so_prefer_busy_poll = SocketOption(69) // SO_PREFER_BUSY_POLL
|
||||
pub const so_priority = SocketOption(12) // SO_PRIORITY
|
||||
pub const so_protocol = SocketOption(38) // SO_PROTOCOL
|
||||
pub const so_rcvbufforce = SocketOption(33) // SO_RCVBUFFORCE
|
||||
pub const so_rcvbuf = SocketOption(8) // SO_RCVBUF
|
||||
pub const so_rcvlowat = SocketOption(18) // SO_RCVLOWAT
|
||||
pub const so_rcvmark = SocketOption(75) // SO_RCVMARK
|
||||
pub const so_rcvpriority = SocketOption(82) // SO_RCVPRIORITY
|
||||
pub const so_rcvtimeo = SocketOption(20) // SO_RCVTIMEO
|
||||
pub const so_rcvtimeo_new = SocketOption(66) // SO_RCVTIMEO_NEW
|
||||
pub const so_rcvtimeo_old = SocketOption(20) // SO_RCVTIMEO_OLD
|
||||
pub const so_reserve_mem = SocketOption(73) // SO_RESERVE_MEM
|
||||
pub const so_reuseaddr = SocketOption(2) // SO_REUSEADDR
|
||||
pub const so_reuseport = SocketOption(15) // SO_REUSEPORT
|
||||
pub const so_rxq_ovfl = SocketOption(40) // SO_RXQ_OVFL
|
||||
pub const so_security_authentication = SocketOption(22) // SO_SECURITY_AUTHENTICATION
|
||||
pub const so_security_encryption_network = SocketOption(24) // SO_SECURITY_ENCRYPTION_NETWORK
|
||||
pub const so_security_encryption_transport = SocketOption(23) // SO_SECURITY_ENCRYPTION_TRANSPORT
|
||||
pub const so_select_err_queue = SocketOption(45) // SO_SELECT_ERR_QUEUE
|
||||
pub const so_sndbufforce = SocketOption(32) // SO_SNDBUFFORCE
|
||||
pub const so_sndbuf = SocketOption(7) // SO_SNDBUF
|
||||
pub const so_sndlowat = SocketOption(19) // SO_SNDLOWAT
|
||||
pub const so_sndtimeo = SocketOption(21) // SO_SNDTIMEO
|
||||
pub const so_sndtimeo_new = SocketOption(67) // SO_SNDTIMEO_NEW
|
||||
pub const so_sndtimeo_old = SocketOption(21) // SO_SNDTIMEO_OLD
|
||||
pub const so_timestamping = SocketOption(37) // SO_TIMESTAMPING
|
||||
pub const so_timestamping_new = SocketOption(65) // SO_TIMESTAMPING_NEW
|
||||
pub const so_timestamping_old = SocketOption(37) // SO_TIMESTAMPING_OLD
|
||||
pub const so_timestampns = SocketOption(35) // SO_TIMESTAMPNS
|
||||
pub const so_timestampns_new = SocketOption(64) // SO_TIMESTAMPNS_NEW
|
||||
pub const so_timestampns_old = SocketOption(35) // SO_TIMESTAMPNS_OLD
|
||||
pub const so_timestamp = SocketOption(29) // SO_TIMESTAMP
|
||||
pub const so_timestamp_new = SocketOption(63) // SO_TIMESTAMP_NEW
|
||||
pub const so_timestamp_old = SocketOption(29) // SO_TIMESTAMP_OLD
|
||||
pub const so_txrehash = SocketOption(74) // SO_TXREHASH
|
||||
pub const so_txtime = SocketOption(61) // SO_TXTIME
|
||||
pub const so_type = SocketOption(3) // SO_TYPE
|
||||
pub const so_wifi_status = SocketOption(41) // SO_WIFI_STATUS
|
||||
pub const so_zerocopy = SocketOption(60) // SO_ZEROCOPY
|
||||
Executable
BIN
Binary file not shown.
@@ -1,5 +1,18 @@
|
||||
import netio
|
||||
|
||||
/*
|
||||
This program starts a server that listens for TCP connections on port 1081.
|
||||
The program listens on all addresses available in the operating system,
|
||||
including IPv4 and IPv6.
|
||||
|
||||
Run the program and try connecting using the telnet utility:
|
||||
|
||||
telnet 127.0.0.1 1081 # IPv4
|
||||
telnet ::1 1081 # IPv6
|
||||
|
||||
This program fails if operation system does not support IPv6 or IPv6 is disabled.
|
||||
*/
|
||||
|
||||
fn main() {
|
||||
// We want to bind a server socket to the all available local addresses,
|
||||
// (both IPv4 and IPv6) so collect the address info entries for it.
|
||||
@@ -58,43 +71,37 @@ fn main() {
|
||||
|
||||
println('Listening on ${listen_addr}...')
|
||||
|
||||
// Accept the connection from remote. This is a blocking call.
|
||||
// conn will store the new socket connected to the remote.
|
||||
conn, remote_addr := socket.accept() or {
|
||||
eprintln('ACCEPT: ${err}')
|
||||
exit(1)
|
||||
for {
|
||||
// Accept the connection from remote. This is a blocking call.
|
||||
// conn will store the new socket connected to the remote.
|
||||
conn, remote_addr := socket.accept() or {
|
||||
eprintln('ACCEPT: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Close connection on exit.
|
||||
defer {
|
||||
conn.close() or { panic(err) }
|
||||
}
|
||||
|
||||
// Get remote host and port in numeric format.
|
||||
remote_host, remote_port := netio.name_info(remote_addr,
|
||||
flags: netio.ni_numerichost | netio.ni_numericserv
|
||||
)!
|
||||
|
||||
eprintln('Accepted connection. Remote address: ${remote_host}, remote port: ${remote_port}')
|
||||
|
||||
// Read 512 bytes of data from socket.
|
||||
mut buf := []u8{len: 512} // Initialize the buffer to store message.
|
||||
// Receive data and write it to the buffer.
|
||||
read := conn.recv(mut buf, 0) or {
|
||||
eprintln('RECV: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Create a string from buffer without the trailing zeros.
|
||||
msg := unsafe { tos_clone(buf.data) }
|
||||
|
||||
eprintln('Received from client: ${read} bytes, data: ${msg}')
|
||||
}
|
||||
|
||||
// Close connection on exit.
|
||||
defer {
|
||||
conn.close() or { panic(err) }
|
||||
}
|
||||
|
||||
// Get remote host and port in numeric format.
|
||||
remote_host, remote_port := netio.name_info(remote_addr,
|
||||
flags: netio.ni_numerichost | netio.ni_numericserv
|
||||
)!
|
||||
|
||||
eprintln('Accpeted connection. Remote address: ${remote_host}, remote port: ${remote_port}')
|
||||
|
||||
// Read 512 bytes of data from socket.
|
||||
mut buf := []u8{len: 512} // Initialize the buffer to store message.
|
||||
// Receive data and write it to the buffer.
|
||||
read := conn.recv(mut buf, 0) or {
|
||||
eprintln('RECV: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Create a string from buffer without the trailing zeros.
|
||||
msg := unsafe { tos_clone(buf.data) }
|
||||
|
||||
eprintln('Received from client: ${read} bytes, data: ${msg}')
|
||||
|
||||
// Send reply to the client.
|
||||
sent := conn.send(msg.bytes(), 0) or {
|
||||
eprintln('SEND: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
eprintln('Sent to the client: ${sent} bytes, data: ${msg}')
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ pub fn (e NetworkInterfaceNotFound) msg() string {
|
||||
}
|
||||
|
||||
// name_to_index translates the network interface name to index.
|
||||
// See also if_nametoindex(3).
|
||||
// See also [if_nametoindex(3p)](https://man7.org/linux/man-pages/man3/if_nametoindex.3p.html).
|
||||
pub fn name_to_index(name string) !u32 {
|
||||
index := C.if_nametoindex(&char(name.str))
|
||||
if index == 0 {
|
||||
@@ -47,7 +47,7 @@ pub fn name_to_index(name string) !u32 {
|
||||
}
|
||||
|
||||
// index_to_name translates the network interface index to name e.g. 'eth0'.
|
||||
// See also if_indextoname(3).
|
||||
// See also [if_indextoname(3p)](https://man7.org/linux/man-pages/man3/if_indextoname.3p.html).
|
||||
pub fn index_to_name(index u32) !string {
|
||||
name := []u8{len: C.IF_NAMESIZE}
|
||||
ifname := C.if_indextoname(index, name.data)
|
||||
@@ -92,7 +92,8 @@ pub fn find_network_interface(s string) !NetworkInterfaceId {
|
||||
}
|
||||
}
|
||||
|
||||
// network_interfaces returns an array with names and indexes of all network interfaces in system.
|
||||
// network_interfaces returns an array with names and indexes of all network interfaces on system.
|
||||
// See also [if_nameindex(3p)](https://man7.org/linux/man-pages/man3/if_nameindex.3p.html).
|
||||
pub fn network_interfaces() ![]NetworkInterfaceId {
|
||||
ifaces := C.if_nameindex()
|
||||
if isnil(ifaces) {
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env -S v run
|
||||
#!/usr/bin/env v
|
||||
|
||||
import os
|
||||
import rand
|
||||
@@ -49,7 +49,7 @@ fn main() {
|
||||
println("\tThis file is generated by make.vsh, DO NOT EDIT.")
|
||||
println("*/\n")
|
||||
for k, v in cdefs {
|
||||
println("pub const ${k} = ${v.vtype}(${v.value})")
|
||||
println("pub const ${k} = ${v.vtype}(${v.value}) // ${k.to_upper_ascii()}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
program_linux='
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
'
|
||||
|
||||
program_freebsd='
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
'
|
||||
|
||||
system=$(uname -s)
|
||||
|
||||
case $system in
|
||||
Linux) PROGRAM=$program_linux;;
|
||||
FreeBSD) PROGRAM=$program_freebsd;;
|
||||
*) echo $0: $system is unsupported >&2; exit 1;;
|
||||
esac
|
||||
|
||||
KIND=$1
|
||||
KIND=${KIND:-"SocketType,SocketLevel,SocketOption,AddrFamily,AddrInfoFlag,NameInfoFlag,MsgFlag"}
|
||||
|
||||
echo module netio
|
||||
echo
|
||||
echo '/*'
|
||||
echo -e "\tThis file is generated by mkconst.sh, DO NOT EDIT."
|
||||
echo '*/'
|
||||
echo
|
||||
|
||||
echo "$PROGRAM" | ${CC:-"cc"} -x c - -E -dM ${CFLAGS:-""} |
|
||||
awk -v KIND=$KIND '
|
||||
$1 != "#define" || $2 ~ /\(/ || $3 == "" {next}
|
||||
$2 ~ /^_/ {next}
|
||||
$2 ~ /^[a-z]/ {next}
|
||||
$2 ~ /^SOCK_/ && KIND ~ "SocketType" {printf "pub const %s = SocketType(C.%s)\n", tolower($2), $2}
|
||||
$2 ~ /^(SOL|IPPROTO)_/ && KIND ~ "SocketLevel" {printf "pub const %s = SocketLevel(C.%s)\n", tolower($2), $2}
|
||||
$2 ~ /^(SO|IP|IPV6)_/ && KIND ~ "SocketOption" {printf "pub const %s = SocketOption(C.%s)\n", tolower($2), $2}
|
||||
$2 ~ /^AF_/ && KIND ~ "AddrFamily" {printf "pub const %s = AddrFamily(C.%s)\n", tolower($2), $2}
|
||||
$2 ~ /^AI_/ && KIND ~ "AddrInfoFlag" {printf "pub const %s = AddrInfoFlag(C.%s)\n", tolower($2), $2}
|
||||
$2 ~ /^NI_/ && KIND ~ "NameInfoFlag" {printf "pub const %s = NameInfoFlag(C.%s)\n", tolower($2), $2}
|
||||
$2 ~ /^MSG_/ && KIND ~ "MsgFlag" {printf "pub const %s = MsgFlag(C.%s)\n", tolower($2), $2}
|
||||
KIND ~ "Any" {printf "%s\n", $0}
|
||||
{next}' | sort -k 2 -V
|
||||
@@ -17,11 +17,11 @@ pub type SocketLevel = int
|
||||
// The socket option type.
|
||||
pub type SocketOption = int
|
||||
|
||||
// Flag type for `translate_addr()`.
|
||||
// Flag type for `addr_info()`.
|
||||
// See [getaddrinfo(3)](https://man7.org/linux/man-pages/man3/getaddrinfo.3.html) for details.
|
||||
pub type AddrInfoFlag = int
|
||||
|
||||
// Flag type for `translate_name()`.
|
||||
// Flag type for `name_info()`.
|
||||
// See [getnameinfo(3)](https://man7.org/linux/man-pages/man3/getnameinfo.3.html) for details.
|
||||
pub type NameInfoFlag = int
|
||||
|
||||
|
||||
+14
-7
@@ -24,7 +24,7 @@ pub:
|
||||
fd int = -1
|
||||
}
|
||||
|
||||
// Socket.new creates new socket.
|
||||
// Socket.new creates the new socket.
|
||||
// See [socket(7)](https://www.man7.org/linux/man-pages/man7/socket.7.html) and
|
||||
// [socket(3)](https://man7.org/linux/man-pages/man3/socket.3p.html) for details.
|
||||
pub fn Socket.new(domain AddrFamily, st SocketType, proto Protocol) !Socket {
|
||||
@@ -37,9 +37,8 @@ pub fn Socket.new(domain AddrFamily, st SocketType, proto Protocol) !Socket {
|
||||
}
|
||||
}
|
||||
|
||||
// type reports the actual socket type.
|
||||
// type reports the actual socket type. Look for `sock_*` constants.
|
||||
pub fn (s Socket) type() !SocketType {
|
||||
// return s.get_option_int(sol_socket, so_type)!
|
||||
return s.get_option[SocketType](sol_socket, so_type)!
|
||||
}
|
||||
|
||||
@@ -50,14 +49,14 @@ pub enum Shutdown {
|
||||
read_and_write
|
||||
}
|
||||
|
||||
// connect connects a socket.
|
||||
// connect connects a socket. See [connect(3p)](https://man7.org/linux/man-pages/man3/connect.3p.html) for details.
|
||||
pub fn (s Socket) connect(addr SocketAddr) ! {
|
||||
if C.connect(s.fd, addr.ptr(), addr.size()) == -1 {
|
||||
return os.last_error()
|
||||
}
|
||||
}
|
||||
|
||||
// bind binds a name to a socket.
|
||||
// bind binds a name to a socket. See [bind(3p)](https://man7.org/linux/man-pages/man3/bind.3p.html) for details.
|
||||
pub fn (s Socket) bind(addr SocketAddr) ! {
|
||||
if C.bind(s.fd, addr.ptr(), addr.size()) == -1 {
|
||||
return os.last_error()
|
||||
@@ -65,6 +64,7 @@ pub fn (s Socket) bind(addr SocketAddr) ! {
|
||||
}
|
||||
|
||||
// listen starts listening for socket connections and limit the queue of incoming connections.
|
||||
// See [listen(3p)](https://man7.org/linux/man-pages/man3/listen.3p.html) for details.
|
||||
pub fn (s Socket) listen(backlog int) ! {
|
||||
if C.listen(s.fd, backlog) == -1 {
|
||||
return os.last_error()
|
||||
@@ -73,6 +73,7 @@ pub fn (s Socket) listen(backlog int) ! {
|
||||
|
||||
// accept accepts a new connection on a socket.
|
||||
// The return values are the new socket connected to remote and the remote socket address.
|
||||
// See [accept(3p)](https://man7.org/linux/man-pages/man3/accept.3p.html) for details.
|
||||
pub fn (s Socket) accept() !(Socket, SocketAddr) {
|
||||
mut sock_addr_storage := &C.sockaddr_storage{}
|
||||
mut sock_addr_len := sizeof(C.sockaddr_storage)
|
||||
@@ -113,8 +114,8 @@ fn (s Socket) get_option_raw(level SocketLevel, option SocketOption, mut value v
|
||||
// ```v
|
||||
// import netio
|
||||
// mut socket := netio.Socket.new(netio.af_inet, netio.sock_stream, 0)!
|
||||
// socket.set_option(netio.sol_socket, netio.so_reuseaddr, true)!
|
||||
// assert socket.get_option[bool](netio.sol_socket, netio.so_reuseaddr)! == true
|
||||
// socket.set_option(netio.sol_socket, netio.so_reuseaddr, 1)!
|
||||
// assert socket.get_option[int](netio.sol_socket, netio.so_reuseaddr)! == 1
|
||||
// ```
|
||||
pub fn (s Socket) get_option[T](level SocketLevel, option SocketOption) !T {
|
||||
mut result := T{}
|
||||
@@ -124,6 +125,7 @@ pub fn (s Socket) get_option[T](level SocketLevel, option SocketOption) !T {
|
||||
}
|
||||
|
||||
// receive a message from a connected socket.
|
||||
// See [recv(3p)](https://man7.org/linux/man-pages/man3/recv.3p.html) for details.
|
||||
pub fn (s Socket) recv(mut buf []u8, flags MsgFlag) !int {
|
||||
r := C.recv(s.fd, buf.data, buf.len, flags)
|
||||
if r == -1 {
|
||||
@@ -133,6 +135,7 @@ pub fn (s Socket) recv(mut buf []u8, flags MsgFlag) !int {
|
||||
}
|
||||
|
||||
// receive a message from a connected socket.
|
||||
// See [recvfrom(3p)](https://man7.org/linux/man-pages/man3/recvfrom.3p.html) for details.
|
||||
pub fn (s Socket) recv_from(mut buf []u8, flags MsgFlag) !(int, SocketAddr) {
|
||||
mut sock_addr_storage := &C.sockaddr_storage{}
|
||||
mut sock_addr_len := sizeof(C.sockaddr_storage)
|
||||
@@ -144,6 +147,7 @@ pub fn (s Socket) recv_from(mut buf []u8, flags MsgFlag) !(int, SocketAddr) {
|
||||
}
|
||||
|
||||
// send a message on socket.
|
||||
// See [send(3p)](https://man7.org/linux/man-pages/man3/send.3p.html) for details.
|
||||
pub fn (s Socket) send(buf []u8, flags MsgFlag) !int {
|
||||
r := C.send(s.fd, buf.data, buf.len, flags)
|
||||
if r == -1 {
|
||||
@@ -153,6 +157,7 @@ pub fn (s Socket) send(buf []u8, flags MsgFlag) !int {
|
||||
}
|
||||
|
||||
// send a message on socket using the dst socket address as destination instead of the socket peer address.
|
||||
// See [sendto(3p)](https://man7.org/linux/man-pages/man3/sendto.3p.html) for details.
|
||||
pub fn (s Socket) send_to(buf []u8, dst SocketAddr, flags MsgFlag) !int {
|
||||
r := C.sendto(s.fd, buf.data, buf.len, flags, dst.ptr(), dst.size())
|
||||
if r == -1 {
|
||||
@@ -162,6 +167,7 @@ pub fn (s Socket) send_to(buf []u8, dst SocketAddr, flags MsgFlag) !int {
|
||||
}
|
||||
|
||||
// shutdown shut downs socket send and receive operations.
|
||||
// See [shutodwn(3p)](https://man7.org/linux/man-pages/man3/shutdown.3p.html) for details.
|
||||
pub fn (s Socket) shutdown(how Shutdown) ! {
|
||||
if C.shutdown(s.fd, i32(how)) == -1 {
|
||||
return os.last_error()
|
||||
@@ -169,6 +175,7 @@ pub fn (s Socket) shutdown(how Shutdown) ! {
|
||||
}
|
||||
|
||||
// close closes the socket.
|
||||
// See [close(3p)](https://man7.org/linux/man-pages/man3/close.3p.html) for details.
|
||||
pub fn (s Socket) close() ! {
|
||||
if C.close(s.fd) == -1 {
|
||||
return os.last_error()
|
||||
|
||||
+22
-12
@@ -30,25 +30,32 @@ pub fn SocketAddr.new_ipv4(addr [4]u8, port u16) SocketAddr {
|
||||
return sock_addr
|
||||
}
|
||||
|
||||
@[params]
|
||||
pub struct Inet6SocketAddrParams {
|
||||
pub:
|
||||
flow_info u32
|
||||
scope_id u32
|
||||
}
|
||||
|
||||
// SocketAddr.new_ipv6 creates new AF_INET6 socket address.
|
||||
// addr must be set in network (big-endian) byte order.
|
||||
// Use `find_network_interface()` to get an integer scope_id from its string representation.
|
||||
pub fn SocketAddr.new_ipv6(addr [16]u8, port u16, flow_info u32, scope_id u32) SocketAddr {
|
||||
pub fn SocketAddr.new_ipv6(addr [16]u8, port u16, params Inet6SocketAddrParams) SocketAddr {
|
||||
mut sock_addr := unsafe { SocketAddr.new(af_inet6, 28) }
|
||||
unsafe {
|
||||
sock_addr.write(binary.big_endian_get_u16(port)) or {}
|
||||
sock_addr.write(binary.big_endian_get_u32(flow_info)) or {}
|
||||
sock_addr.write(binary.big_endian_get_u32(params.flow_info)) or {}
|
||||
sock_addr.write(addr[..]) or {}
|
||||
sock_addr.write(binary.big_endian_get_u32(scope_id)) or {}
|
||||
sock_addr.write(binary.big_endian_get_u32(params.scope_id)) or {}
|
||||
}
|
||||
return sock_addr
|
||||
}
|
||||
|
||||
// SocketAddr.new_unix creates new AF_UNIX socket address with given path. The path must
|
||||
// fit in platform dependent const `max_unix_path_len` value.
|
||||
// fit in platform dependent `max_unix_path_len` const value.
|
||||
pub fn SocketAddr.new_unix(path string) !SocketAddr {
|
||||
if path.len > max_unix_path_len {
|
||||
return error('Too long path to socket')
|
||||
return error('too long path to socket, max length is ${max_unix_path_len}')
|
||||
}
|
||||
mut sock_addr := unsafe { SocketAddr.new(af_unix, usize(max_unix_path_len) + 2) }
|
||||
unsafe {
|
||||
@@ -141,7 +148,7 @@ pub fn SocketAddr.from_ptr_copy(ptr voidptr, size isize) !SocketAddr {
|
||||
}
|
||||
|
||||
// SocketAddr.from_ptr creates new socket address from specified pointer.
|
||||
// Note: The data is reused, not copied. See also SocketAddr.from_ptr_copy().
|
||||
// Note: Data is reused, not copied.
|
||||
@[unsafe]
|
||||
pub fn SocketAddr.from_ptr(ptr voidptr, size isize) !SocketAddr {
|
||||
if isnil(ptr) {
|
||||
@@ -164,8 +171,8 @@ pub fn (a SocketAddr) family() AddrFamily {
|
||||
return f
|
||||
}
|
||||
|
||||
// is_empty returns true if socket address is unspecified — the data pointer is nil or
|
||||
// data contains only zeros. Empty address cannot be used in `bind` and `connect` calls.
|
||||
// is_empty returns true if socket address is unspecified: the data pointer is nil or socket
|
||||
// address data is zero. Empty address cannot be used in `bind()` and `connect()` calls.
|
||||
pub fn (a SocketAddr) is_empty() bool {
|
||||
if isnil(a.data) {
|
||||
return true
|
||||
@@ -216,10 +223,13 @@ pub fn (a SocketAddr) size() u32 {
|
||||
}
|
||||
|
||||
// str returns the string representation of socket address.
|
||||
// Supported address families are AF_INET, AF_INET6, and AF_UNIX.
|
||||
// Examples: '172.16.16.132:1080', '[fdf1:72d1:0033:0000:0000:0000:0000:0247]:25535',
|
||||
// '/run/app.sock'. For others a string like 'SocketAddr(0x00000000)' will be returned.
|
||||
// See also `translate_name()`.
|
||||
// Only AF_UNIX, AF_INET, and AF_INET6 are supported. str will return a string
|
||||
// consisting of the address and port number separated by a colon, or the absolute
|
||||
// path to the socket file. The IPv6 address will be returned in expanded form and
|
||||
// enclosed in square brackets. For all other address families, str will return a
|
||||
// string of the form `SocketAddr(0x00000000)` with the socket address data pointer
|
||||
// in brackets.
|
||||
// Note: See also `name_info()`.
|
||||
pub fn (a SocketAddr) str() string {
|
||||
match a.family() {
|
||||
af_inet {
|
||||
|
||||
Reference in New Issue
Block a user