| ... | @@ -397,13 +397,12 @@ pub const AddressList = struct { | ... | @@ -397,13 +397,12 @@ pub const AddressList = struct { |
| 397 | | 397 | |
| 398 | /// All memory allocated with `allocator` will be freed before this function returns. | 398 | /// All memory allocated with `allocator` will be freed before this function returns. |
| 399 | pub fn tcpConnectToHost(allocator: *mem.Allocator, name: []const u8, port: u16) !fs.File { | 399 | pub fn tcpConnectToHost(allocator: *mem.Allocator, name: []const u8, port: u16) !fs.File { |
| 400 | const list = getAddressList(allocator, name, port); | 400 | const list = try getAddressList(allocator, name, port); |
| 401 | defer list.deinit(); | 401 | defer list.deinit(); |
| 402 | | 402 | |
| 403 | const addrs = list.addrs.toSliceConst(); | 403 | if (list.addrs.len == 0) return error.UnknownHostName; |
| 404 | if (addrs.len == 0) return error.UnknownHostName; | | |
| 405 | | 404 | |
| 406 | return tcpConnectToAddress(addrs[0], port); | 405 | return tcpConnectToAddress(list.addrs[0]); |
| 407 | } | 406 | } |
| 408 | | 407 | |
| 409 | pub fn tcpConnectToAddress(address: Address) !fs.File { | 408 | pub fn tcpConnectToAddress(address: Address) !fs.File { |