Socket API

Updated: April 19, 2023

The io-sock networking stack provides socket functions ported from FreeBSD as well as io-sock-specific ones.

The FreeBSD documentation provides reference and other information about socket functions. For example: https://docs.freebsd.org/en_US.ISO8859-1/books/developers-handbook/sockets-essential-functions.html.

The io-sock networking stack supports all the routines that application programmers would expect, including (but not limited to) the functions listed below. The FreeBSD 13.0 manual pages at https://www.freebsd.org/cgi/man.cgi are the best guide to their use:

accept()
accept4()
bind()
bindresvport()
bindresvport_sa()
connect()
dn_comp()
dn_expand()
endnetent()
endnetgrent()
endprotoent()
endservent()
ether_aton()
ether_hostton()
ether_line()
ether_ntoa()
ether_ntohost()
feature_present()
freeaddrinfo()
freeifaddrs()
freeifmaddrs()
gai_strerror()
getaddrinfo()
getdomainname()
getifaddrs()
getifmaddrs()
getnameinfo()
getnetbyaddr()
getnetbyname()
getnetent()
getnetgrent()
getpeereid()
getpeername()
getprotobyname()
getprotobyname_r()
getprotobynumber()
getprotobynumber_r()

getprotoent()
getprotoent_r()
getservbyname_r()
getservbyport()
getservbyport_r()
getservent()
getservent_r()
getsockname()
getsockopt()
htonl()
htons()
if_freenameindex()
if_indextoname()
if_nameindex()
if_nametoindex()
inet_addr()
inet_aton()
inet_lnaof()
inet_makeaddr()
inet_net_ntop()
inet_net_pton()
inet_netof()
inet_network()
inet_ntoa()
inet_ntoa_r()
inet_ntop()
inet_pton()
inet6_opt_append()
inet6_opt_find()
inet6_opt_finish()
inet6_opt_get_val()
inet6_opt_init()
inet6_opt_next()
inet6_opt_set_val()
inet6_rth_add()
inet6_rth_getaddr()
inet6_rth_init()

inet6_rth_reverse()
inet6_rth_segments()
inet6_rth_space()
innetgr()
link_addr()
link_ntoa()
listen()
nsdispatch()
ntohl()
ntohs()
recv()
recvfrom()
recvmmsg()
recvmsg()
res_init()
res_mkquery()
res_query()
res_querydomain()
res_search()
res_send()
send()
sendto()
sendmmsg()
sendmsg()
setnetent()
setnetgrent()
setprotoent()
setservent()
setsockopt()
shutdown()
sockatmark()
socket()
sysctlbyname()
sysctlbynamefb()
sysctlnametomib()
sysctlnametomibfd()

The following functions were added with io-sock and are documented in this guide:

The io-sock networking stack ports the in6_addr structures from FreeBSD. For information on the IPv6 address that they correspond to, see in6addr_*.

Deprecated functions

The following table lists APIs that FreeBSD has deprecated and the functions that replace them:

Instead of: Use: FreeBSD manual pages
inet6_option_space, inet6_option_init, inet6_option_append, inet6_option_alloc, inet6_option_next, inet6_option_find inet6_opt_init, inet6_opt_append, inet6_opt_finish, inet6_opt_set_val, inet6_opt_next, inet6_opt_find, inet6_opt_get_val inet6_opt_init()
inet6_rthdr_space, inet6_rthdr_init, inet6_rthdr_add, inet6_rthdr_lasthop, inet6_rthdr_reverse, inet6_rthdr_segments,inet6_rthdr_getaddr, inet6_rthdr_getflags inet6_rth_space, inet6_rth_init, inet6_rth_add, inet6_rth_reverse, inet6_rth_segments, inet6_rth_getaddr inet6_rthdr_space()
endhostent(), gethostbyaddr(), gethostbyaddr_r(), gethostbyname(), gethostbyname_r(), gethostbyname2(), gethostbyname2_r(), gethostent(), gethostent_r() , getservbyname(), h_errno(), herror(), hstrerror(), sethostent getaddrinfo(), getnameinfo() getaddrinfo(), getnameinfo()