From 17ba6ecf840e743db2a2a305df73070d0eb69217 Mon Sep 17 00:00:00 2001 From: Nic Gaffney Date: Tue, 20 Oct 2026 04:12:48 -0500 Subject: reorganized --- src/bin/main.zig | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/bin/main.zig') diff --git a/src/bin/main.zig b/src/bin/main.zig index 634676d..6784263 100644 --- a/src/bin/main.zig +++ b/src/bin/main.zig @@ -1,7 +1,6 @@ const std = @import("std"); const Io = std.Io; -const Response = @import("response.zig"); -const App = Response.App; +const App = @import("app.zig"); const nv = @import("nvlope"); @@ -10,7 +9,7 @@ pub fn main(init: std.process.Init) !void { const alloc = std.heap.smp_allocator; // Initialize server on localhost at the specified port - const port = 8080; + const port = 2525; const addr = try Io.net.IpAddress.parse("127.0.0.1", port); var server = try addr.listen(io, .{ .mode = .stream, @@ -22,8 +21,9 @@ pub fn main(init: std.process.Init) !void { var group: Io.Group = .init; defer group.cancel(io); + // Async delivery worker here + while (true) { - std.debug.print("Waiting for conn...\n", .{}); const stream = try server.accept(io); group.async(io, serve, .{ alloc, io, stream }); } @@ -52,7 +52,7 @@ fn session(alloc: std.mem.Allocator, io: Io, stream: *Io.net.Stream) !void { var app: App = .{ .gpa = alloc }; // Greeting: the server speaks first - try nv.Reply.single(.ready, "localhost ESMTP ready").send(w); + try nv.Reply.single(.ready, "nvlope ready").send(w); try w.flush(); var in_data = false; @@ -74,6 +74,7 @@ fn session(alloc: std.mem.Allocator, io: Io, stream: *Io.net.Stream) !void { in_data = false; try nv.Reply.single(.ok, "Queued").send(w); try w.flush(); + std.debug.print("App {{\n\t body: {s}\n\tsender: {s}\n\trecipients: {any}\n}}\n", .{ app.body.items, app.sender.?, app.recipients.items }); } else { const status = try app.appendBodyLine(line); switch (status) { -- cgit v1.2.3