mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
17 lines
497 B
C
17 lines
497 B
C
module std::net::udp @if(os::SUPPORTS_INET);
|
|
import std::net @public;
|
|
|
|
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_from_addrinfo(ai, options);
|
|
}
|