authorgravatar for grownned@gmail.comRichalsu <grownned@gmail.com> 2026-05-07 18:40:34+03:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-08-15 10:46:35+02:00
logf506a49142cdb8454c70acd662bf7e45289ddae2
tree053938d50ff51cefe508f314970932d669442314
parenta72236ae8e9f11f42351ae42b1242f6091216c45

std.Io: add error.ConnectionTimedOut for net read/write/send/receive


4 files changed, 21 insertions(+), 2 deletions(-)

lib/std/Io.zig+13-2
......@@ -373,6 +373,9 @@ pub const Operation = union(enum) {
373373 /// the OS where it was queued up to be reported at the next call
374374 /// to send or receive on the bound socket.
375375 PortUnreachable,
376 /// The remote peer did not respond to ongoing communication, causing the
377 /// OS to abort the connection.
378 ConnectionTimedOut,
376379 } || Io.UnexpectedError;
377380
378381 pub const Result = struct { ?net.Socket.ReceiveError, usize };
......@@ -416,6 +419,9 @@ pub const Operation = union(enum) {
416419 /// An attempt was made to send to a network/broadcast address as
417420 /// though it was a unicast address.
418421 AccessDenied,
422 /// The remote peer did not respond to ongoing communication, causing the
423 /// OS to abort the connection.
424 ConnectionTimedOut,
419425 } || Io.UnexpectedError;
420426
421427 pub const Result = struct { ?net.Socket.SendError, usize };
......@@ -429,10 +435,12 @@ pub const Operation = union(enum) {
429435 SystemResources,
430436 ConnectionResetByPeer,
431437 SocketUnconnected,
432 /// The file descriptor does not hold the required rights to read
433 /// from it.
438 /// File descriptor does not hold the required rights to read from it.
434439 AccessDenied,
435440 NetworkDown,
441 /// The remote peer did not respond to ongoing communication, causing the
442 /// OS to abort the connection.
443 ConnectionTimedOut,
436444 } || Io.UnexpectedError;
437445
438446 pub const Result = Error!usize;
......@@ -469,6 +477,9 @@ pub const Operation = union(enum) {
469477 /// Local end has been shut down on a connection-oriented socket, or
470478 /// the socket was never connected.
471479 SocketUnconnected,
480 /// The remote peer did not respond to ongoing communication, causing the
481 /// OS to abort the connection.
482 ConnectionTimedOut,
472483 SocketNotBound,
473484 } || Io.UnexpectedError;
474485
lib/std/Io/Threaded.zig+6
......@@ -12883,6 +12883,7 @@ fn netReadPosix(fd: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usi
1288312883 .NOMEM => return error.SystemResources,
1288412884 .NOTCONN => return error.SocketUnconnected,
1288512885 .CONNRESET => return error.ConnectionResetByPeer,
12886 .TIMEDOUT => return error.ConnectionTimedOut,
1288612887 .NOTCAPABLE => return error.AccessDenied,
1288712888 else => |err| return posix.unexpectedErrno(err),
1288812889 }
......@@ -12914,6 +12915,7 @@ fn netReadPosix(fd: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usi
1291412915 .NOMEM => return error.SystemResources,
1291512916 .NOTCONN => return error.SocketUnconnected,
1291612917 .CONNRESET => return error.ConnectionResetByPeer,
12918 .TIMEDOUT => return error.ConnectionTimedOut,
1291712919 .PIPE => return error.SocketUnconnected,
1291812920 .NETDOWN => return error.NetworkDown,
1291912921 else => |err| return posix.unexpectedErrno(err),
......@@ -13077,6 +13079,7 @@ fn netSendOnePosix(
1307713079 .HOSTUNREACH => return syscall.fail(error.HostUnreachable),
1307813080 .NETUNREACH => return syscall.fail(error.NetworkUnreachable),
1307913081 .NOTCONN => return syscall.fail(error.SocketUnconnected),
13082 .TIMEDOUT => return syscall.fail(error.ConnectionTimedOut),
1308013083 .NETDOWN => return syscall.fail(error.NetworkDown),
1308113084 .BADF => |err| return syscall.errnoBug(err), // File descriptor used after closed.
1308213085 .DESTADDRREQ => |err| return syscall.errnoBug(err),
......@@ -13148,6 +13151,7 @@ fn netSendManyPosix(
1314813151 .HOSTUNREACH => return syscall.fail(error.HostUnreachable),
1314913152 .NETUNREACH => return syscall.fail(error.NetworkUnreachable),
1315013153 .NOTCONN => return syscall.fail(error.SocketUnconnected),
13154 .TIMEDOUT => return syscall.fail(error.ConnectionTimedOut),
1315113155 .NETDOWN => return syscall.fail(error.NetworkDown),
1315213156
1315313157 .BADF => |err| return syscall.errnoBug(err), // File descriptor used after closed.
......@@ -13228,6 +13232,7 @@ fn netReceivePosix(
1322813232 .MSGSIZE => return syscall.fail(error.MessageOversize),
1322913233 .PIPE => return syscall.fail(error.SocketUnconnected),
1323013234 .CONNRESET => return syscall.fail(error.ConnectionResetByPeer),
13235 .TIMEDOUT => return syscall.fail(error.ConnectionTimedOut),
1323113236 .NETDOWN => return syscall.fail(error.NetworkDown),
1323213237 .AGAIN => return syscall.fail(error.WouldBlock),
1323313238 .BADF => |err| return syscall.errnoBug(err),
......@@ -13390,6 +13395,7 @@ fn netWritePosix(
1339013395 .HOSTUNREACH => return error.HostUnreachable,
1339113396 .NETUNREACH => return error.NetworkUnreachable,
1339213397 .NOTCONN => return error.SocketUnconnected,
13398 .TIMEDOUT => return error.ConnectionTimedOut,
1339313399 .NETDOWN => return error.NetworkDown,
1339413400 else => |err| return posix.unexpectedErrno(err),
1339513401 }
lib/std/Io/Uring.zig+1
......@@ -5152,6 +5152,7 @@ fn netReceive(
51525152 .PIPE => return .{ error.SocketUnconnected, message_i },
51535153 .OPNOTSUPP => |err| return .{ errnoBug(err), message_i },
51545154 .CONNRESET => return .{ error.ConnectionResetByPeer, message_i },
5155 .TIMEDOUT => return .{ error.ConnectionTimedOut, message_i },
51555156 .NETDOWN => return .{ error.NetworkDown, message_i },
51565157 else => |err| return .{ unexpectedErrno(err), message_i },
51575158 }
src/IncrementalDebugServer.zig+1
......@@ -95,6 +95,7 @@ fn runServer(ids: *IncrementalDebugServer) void {
9595 => |e| log.err("failed to serve '{f}' ({t})", .{ stream.socket.address, e }),
9696
9797 error.EndOfStream,
98 error.ConnectionTimedOut,
9899 error.ConnectionResetByPeer,
99100 => log.info("client '{f}' disconnected", .{stream.socket.address}),
100101