79416611

Date: 2025-02-06 01:55:59
Score: 0.5
Natty:
Report link

I found the answer on Ziggit, posting it here for better reach.

Thank you dimdim for the solution.

const std = @import("std");

pub fn main() !void {
    const sock = try std.posix.socket(std.posix.AF.INET, std.posix.SOCK.DGRAM, std.posix.IPPROTO.UDP);
    defer std.posix.close(sock);

    const addr = try std.net.Address.parseIp("127.0.0.1", 55555);
    try std.posix.bind(sock, &addr.any, addr.getOsSockLen());

    var buf: [1024]u8 = undefined;
    const len = try std.posix.recvfrom(sock, &buf, 0, null, null);
    std.debug.print("recv: {s}\n", .{buf[0..len]});
}
Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Cijin Cherian