A socket binding for MoonBit
moon add fangyinc/socket{
"import": [
"fangyinc/socket/lib"
]
}pub(open) trait ToCString {
to_cstring(self : Self) -> Bytes
}pub(open) trait ToIpaddr {
ip_name(self : Self) -> String raise NetError
to_socket_addr(self : Self) -> SocketAddr raise NetError
to_ipaddr(self : Self) -> Ipaddr raise NetError
}pub(all) enum AIFlags {
AI_PASSIVE
AI_CANONNAME
AI_ALL
AI_NUMERICHOST
AI_NUMERICSERV
AI_ADDRCONFIG
AI_V4MAPPED
}type AddrInfoResultspub(all) enum Domain {
IPv4
IPv6
Unix
}type Ipaddrtype Ipv4addrtype Ipv6addrpub(all) type! NetError String
pub(all) enum Protocol {
TCP
UDP
ICMPV4
ICMPV6
}pub(all) enum Shutdown {
Read
Write
Both
}pub(all) struct Socket {
inner : Int64
}pub(all) enum SocketAddr {
V4(String, UInt16)
V6(String, UInt16, UInt, UInt)
}pub(all) enum Type {
Stream
Datagram
Raw
}fn[H : ToCString, S : ToCString, TDO : ToDomain, ToT : ToType, ToP : ToProtocol] getaddrinfo(hostname : H, service : S, ai_flags : Int, ai_family : TDO, ai_socktype : ToT, ai_protocol : ToP) -> AddrInfoResults raise NetErrorfn mbt_string_to_utf8_bytes(str : String, is_filename : Bool) -> Bytes