mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Order of attribute declaration is changed for `alias`. - Added `LANGUAGE_DEV_VERSION` env constant. - Rename `anyfault` -> `fault`. - Changed `fault` -> `faultdef`. - Added `attrdef` instead of `alias` for attribute aliases.
29 lines
914 B
Plaintext
29 lines
914 B
Plaintext
module std::net::udp @if(os::SUPPORTS_INET);
|
|
import std::net @public;
|
|
|
|
typedef UdpSocket = inline Socket;
|
|
|
|
fn UdpSocket? connect(String host, uint port, SocketOption... options, IpProtocol ip_protocol = UNSPECIFIED)
|
|
{
|
|
AddrInfo* ai = net::addrinfo(host, port, ip_protocol.ai_family, os::SOCK_DGRAM)!;
|
|
defer os::freeaddrinfo(ai);
|
|
return connect_to(ai, ...options);
|
|
}
|
|
|
|
fn UdpSocket? connect_to(AddrInfo* ai, SocketOption... options)
|
|
{
|
|
return (UdpSocket)net::connect_from_addrinfo(ai, options);
|
|
}
|
|
|
|
fn UdpSocket? connect_async(String host, uint port, SocketOption... options, IpProtocol ip_protocol = UNSPECIFIED)
|
|
{
|
|
AddrInfo* ai = net::addrinfo(host, port, ip_protocol.ai_family, os::SOCK_DGRAM)!;
|
|
defer os::freeaddrinfo(ai);
|
|
return connect_async_to(ai, ...options);
|
|
}
|
|
|
|
fn UdpSocket? connect_async_to(AddrInfo* ai, SocketOption... options)
|
|
{
|
|
return (UdpSocket)net::connect_async_from_addrinfo(ai, options);
|
|
}
|