#!/usr/bin/env ferite

/* Run "nc -u localhost 6666", type something in, and press enter. */

uses "console", "network", "sys", "string";

string s;
object sock = new Network.UDPSocket();

sock.bind(Network.ANY4, 6666);

s = sock.recv(4096);
Console.println("Received datagram: \"" + s + "\"");
Console.println("remoteip = " + sock.remoteip);
Console.println("remoteport = " + sock.remoteport);
sock.connect(sock.remoteip, String.toNumber(sock.remoteport), sock.af);
while(1) {
	Sys.sleep(1);
	sock.send("Ping!\n");
}
