hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 3db9b5be54625294d6fc34bf10c44e363a1b04ca
parent da9ccda24913353132344713a8d801909b26f0de
Author: Drew DeVault <sir@cmpwn.com>
Date:   Thu, 24 Jun 2021 13:29:18 -0400

net::dial: rig up udp dialer

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mnet/dial/ip.ha | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/net/dial/ip.ha b/net/dial/ip.ha @@ -20,5 +20,16 @@ fn dial_tcp(addr: str, service: str) (*io::stream | error) = { }; fn dial_udp(addr: str, service: str) (*io::stream | error) = { - abort(); // TODO + const result = resolve("udp", addr, service)?; + const addrs = result.0, port = result.1; + for (let i = 0z; i < len(addrs); i += 1) { + const addr = addrs[i]; + match (udp::connect(addr, port)) { + sock: udp::socket => return udp::stream(sock), + err: net::error => if (i + 1 >= len(addrs)) { + return err; + }, + }; + }; + abort(); // Unreachable };