Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.stdio;
- import std.socket;
- import std.conv;
- import std.process;
- import core.thread;
- void main(string[] argv) {
- if (argv.length == 2) { argv ~= "4455"; }
- if (argv.length != 3) {
- writefln("Usage: %s <server host> <port>", argv[0]);
- return;
- }
- ushort port = parse!ushort(argv[2]);
- auto addr = new InternetAddress(argv[1], port);
- auto s = new UdpSocket();
- writefln("Sending datagrams to %s:%s", addr.toAddrString, port);
- while (true){
- write("\b",progressChar);; stdout.flush;
- s.sendTo(null, addr);
- core.thread.Thread.sleep(dur!("seconds")(3));
- }
- }
- char progressChar() {
- static char[] chars = [ '-', '\\', '|', '/', ];
- static int index = 0;
- if (index == chars.length) index = 0;
- return chars[index++];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement