Skip to content

Commit 55d496d

Browse files
committed
feat(aio): support connect
1 parent feae50e commit 55d496d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/net/lib.zig

+13
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ pub const Net = struct {
1515
try rt.aio.queue_accept(index, socket);
1616
}
1717

18+
pub fn connect(
19+
self: *Net,
20+
task_ctx: anytype,
21+
comptime task_fn: TaskFn(i32, @TypeOf(task_ctx)),
22+
socket: std.posix.socket_t,
23+
host: []const u8,
24+
port: u16,
25+
) !void {
26+
const rt: *Runtime = @alignCast(@fieldParentPtr("net", self));
27+
const index = try rt.scheduler.spawn(i32, task_ctx, task_fn, .waiting);
28+
try rt.aio.queue_connect(index, socket, host, port);
29+
}
30+
1831
pub fn recv(
1932
self: *Net,
2033
task_ctx: anytype,

0 commit comments

Comments
 (0)