| ... | @@ -340,8 +340,8 @@ pub const Address = extern union { | ... | @@ -340,8 +340,8 @@ pub const Address = extern union { |
| 340 | try std.fmt.format(context, Errors, output, "]:{}", port); | 340 | try std.fmt.format(context, Errors, output, "]:{}", port); |
| 341 | }, | 341 | }, |
| 342 | os.AF_UNIX => { | 342 | os.AF_UNIX => { |
| 343 | if (@typeOf(self.un) == void) { | 343 | if (!has_unix_sockets) { |
| 344 | @panic("unsupported OS"); | 344 | unreachable; |
| 345 | } | 345 | } |
| 346 | | 346 | |
| 347 | try std.fmt.format(context, Errors, output, "{}", self.un.path); | 347 | try std.fmt.format(context, Errors, output, "{}", self.un.path); |
| ... | @@ -361,8 +361,8 @@ pub const Address = extern union { | ... | @@ -361,8 +361,8 @@ pub const Address = extern union { |
| 361 | os.AF_INET => return @sizeOf(os.sockaddr_in), | 361 | os.AF_INET => return @sizeOf(os.sockaddr_in), |
| 362 | os.AF_INET6 => return @sizeOf(os.sockaddr_in6), | 362 | os.AF_INET6 => return @sizeOf(os.sockaddr_in6), |
| 363 | os.AF_UNIX => { | 363 | os.AF_UNIX => { |
| 364 | if (@typeOf(self.un) == void) { | 364 | if (!has_unix_sockets) { |
| 365 | @panic("unsupported OS"); | 365 | unreachable; |
| 366 | } | 366 | } |
| 367 | | 367 | |
| 368 | const path_len = std.mem.len(u8, &self.un.path); | 368 | const path_len = std.mem.len(u8, &self.un.path); |
| ... | @@ -1321,12 +1321,6 @@ pub const StreamServer = struct { | ... | @@ -1321,12 +1321,6 @@ pub const StreamServer = struct { |
| 1321 | const nonblock = if (std.io.is_async) os.SOCK_NONBLOCK else 0; | 1321 | const nonblock = if (std.io.is_async) os.SOCK_NONBLOCK else 0; |
| 1322 | const sock_flags = os.SOCK_STREAM | os.SOCK_CLOEXEC | nonblock; | 1322 | const sock_flags = os.SOCK_STREAM | os.SOCK_CLOEXEC | nonblock; |
| 1323 | const proto = if (address.any.family == os.AF_UNIX) @as(u32, 0) else os.IPPROTO_TCP; | 1323 | const proto = if (address.any.family == os.AF_UNIX) @as(u32, 0) else os.IPPROTO_TCP; |
| 1324 | if (address.any.family == os.AF_UNIX and @typeOf(address.un) == void) { | | |
| 1325 | return error{ | | |
| 1326 | /// When the OS does not have support for AF_UNIX sockets. | | |
| 1327 | UnsupportedOS, | | |
| 1328 | }.UnsupportedOS; | | |
| 1329 | } | | |
| 1330 | | 1324 | |
| 1331 | const sockfd = try os.socket(address.any.family, sock_flags, proto); | 1325 | const sockfd = try os.socket(address.any.family, sock_flags, proto); |
| 1332 | self.sockfd = sockfd; | 1326 | self.sockfd = sockfd; |