Next: , Up: Communications Samples   [Index]


13.15.3.1 Time of Day Server

A trivial time-of-day server (writes on each connection the time of day):

file f;

tcpip_listen(f, 40000, 0);

while (1) {
    file i, o;
    date d;

    accept(i, o, f, 0);
    d.now();
    o.form("/f2/:/f2/:/f2/", d.d_hour, d.h_minute, d.m_second);
}

A client, getting the time of day from the server above:

file i, o;
text s;

tcpip_connect(i, o, "127.0.0.1", 40000, 0);
i.line(s);
o_plan(s, "\n");