Finding if port is closed when connecting to UDP server

Hello Everybody hope yall having wonderful day. I need a just quick help am working on an enumeration tool for SNMP. The issue is when i connect to udp port it’s normal that idk if it open or closed, however when sending or receiving i should know then at least that what the normal send, recv syscalls does. Here is the code example am working on.

fn connectSnmp(ip: net.IpAddress, io: Io) !net.Stream {
    const stream = try ip.connect(io, .{ .mode = .dgram, .protocol = .udp, .timeout = .none });
    return stream;
}

pub fn main(init: std.process.Init) !void {
    const io = init.io;
    var gpa = std.heap.DebugAllocator(.{ .verbose_log = true }){};
    const allocator = gpa.allocator();
    _ = allocator;

    const ip = try net.IpAddress.parse("127.0.0.1", 161);

    const stream = try connectSnmp(ip, io);
    var write_buf: [1024]u8 = undefined;
    var writer_handler = stream.writer(io, &write_buf);

    const writer_server = &writer_handler.interface;
    const written = try writer_server.write("Hello world");
    try writer_server.flush();
    _ = written;

    defer stream.close(io);
    std.log.debug("{any}", .{stream.socket.handle});
}

Also i tried to setting a timeout but unfortunately its not implemented yet i got a panic that stated that