mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
16 lines
459 B
C
16 lines
459 B
C
module std::net::udp @if(os::SUPPORTS_INET);
|
|
|
|
def UdpSocket = distinct inline Socket;
|
|
|
|
fn UdpSocket! connect(String host, uint port, SocketOption... options, IpProtocol protocol = UNSPECIFIED)
|
|
{
|
|
AddrInfo* ai = net::addrinfo(host, port, 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(ai, options);
|
|
}
|