# make std.net more portable · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/0de862e8bafce9a58c1018e9b6f81b3d17279c10)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 0de862e8bafce9a58c1018e9b6f81b3d17279c10

Requested commit: 0de862e8bafce9a58c1018e9b6f81b3d17279c10

Commit: 0de862e8bafce9a58c1018e9b6f81b3d17279c10

Tree: d8b75a7683324c713d6fb53023ae6ae88f69e157

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
make std.net more portable

 * Delete `std.net.TmpWinAddr`. I don't think that was ever meant to
   be a real thing.
 * Delete `std.net.OsAddress`. This abstraction was not helpful.
 * Rename `std.net.Address` to `std.net.IpAddress`. It is now an extern
   union of IPv4 and IPv6 addresses.
 * Move `std.net.parseIp4` and `std.net.parseIp6` to the
   `std.net.IpAddress` namespace. They now return `IpAddress` instead of
   `u32` and `std.net.Ip6Addr`, which is deleted.
 * Add `std.net.IpAddress.parse` which accepts a port and parses either
   an IPv4 or IPv6 address.
 * Add `std.net.IpAddress.parseExpectingFamily` which additionally
   accepts a `family` parameter.
 * `std.net.IpAddress.initIp4` and `std.net.IpAddress.initIp6` are
   improved to directly take the address fields instead of a weird
   in-between type.
 * `std.net.IpAddress.port` is renamed to `std.net.IpAddress.getPort`.
 * Added `std.net.IpAddress.setPort`.
 * `os.sockaddr` struct on all targets is improved to match the
   corresponding system struct. Previously I had made it a union of
   sockaddr_in, sockaddr_in6, and sockaddr_un. The new abstraction for
   this is now `std.net.IpAddress`.
 * `os.sockaddr` and related bits are added for Windows.
 * `os.sockaddr` and related bits now have the `zero` fields default
   to zero initialization, and `len` fields default to the correct size.
   This is enough to abstract the differences across targets, and so
   no more switch on the target OS is needed in `std.net.IpAddress`.
 * Add the missing `os.sockaddr_un` on FreeBSD and NetBSD.
 * `std.net.IpAddress.initPosix` now takes a pointer to `os.sockaddr`.

```

## Parents

- [618ee5b63a2f817492b4da0d5c8b7fa1584680bc](https://git.cafe/gitcafe/zig/commit/618ee5b63a2f817492b4da0d5c8b7fa1584680bc?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/0de862e8bafce9a58c1018e9b6f81b3d17279c10?format=markdown)
