Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #121 UDP listen and read

Listen UDP traffic on port p and read 1024 bytes into the buffer b.

import std.socket;
ubyte[1024] b;

auto sock = new UdpSocket();
scope(exit) sock.close;

sock.bind(new InternetAddress(p));
sock.receive(b);

New implementation...
< >
programming-idioms.org