mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
nice error for unsupported async sockets on Windows
This commit is contained in:
parent
29945fb8b3
commit
0134cb0214
@ -894,7 +894,7 @@ pub const Loop = struct {
|
||||
self: *Loop,
|
||||
/// This argument is a socket that has been created with `socket`, bound to a local address
|
||||
/// with `bind`, and is listening for connections after a `listen`.
|
||||
sockfd: os.fd_t,
|
||||
sockfd: os.socket_t,
|
||||
/// This argument is a pointer to a sockaddr structure. This structure is filled in with the
|
||||
/// address of the peer socket, as known to the communications layer. The exact format of the
|
||||
/// address returned addr is determined by the socket's address family (see `socket` and the
|
||||
@ -911,7 +911,7 @@ pub const Loop = struct {
|
||||
/// * `SOCK_CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the
|
||||
/// description of the `O_CLOEXEC` flag in `open` for reasons why this may be useful.
|
||||
flags: u32,
|
||||
) os.AcceptError!os.fd_t {
|
||||
) os.AcceptError!os.socket_t {
|
||||
while (true) {
|
||||
return os.accept(sockfd, addr, addr_size, flags | os.SOCK_NONBLOCK) catch |err| switch (err) {
|
||||
error.WouldBlock => {
|
||||
|
@ -8439,4 +8439,18 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:2:30: error: `.*` cannot be followed by `*`. Are you missing a space?",
|
||||
});
|
||||
|
||||
cases.add("Issue #9165: windows tcp server compilation error",
|
||||
\\const std = @import("std");
|
||||
\\pub const io_mode = .evented;
|
||||
\\pub fn main() !void {
|
||||
\\ if (std.builtin.os.tag == .windows) {
|
||||
\\ _ = try (std.net.StreamServer.init(.{})).accept();
|
||||
\\ } else {
|
||||
\\ @compileError("Unsupported OS");
|
||||
\\ }
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"error: Unsupported OS",
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user