Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
51
Task/Echo-server/Aime/echo-server.aime
Normal file
51
Task/Echo-server/Aime/echo-server.aime
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
void
|
||||
readc(dispatch w, file i, file o, data b)
|
||||
{
|
||||
integer e;
|
||||
data t;
|
||||
|
||||
while (1) {
|
||||
e = f_b_read(i, t, 1 << 10);
|
||||
if (e < 1) {
|
||||
if (e == -1) {
|
||||
w_resign(w, i);
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
e = b_frame(t, '\n');
|
||||
if (e != -1) {
|
||||
e += 1;
|
||||
b_rule(b, -1, t, 0, e);
|
||||
f_data(o, b);
|
||||
w_register(w, o);
|
||||
b_ecopy(b, t, e, ~t - e);
|
||||
} else {
|
||||
b_add(b, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
serve(dispatch w, file s)
|
||||
{
|
||||
file i, o;
|
||||
data b;
|
||||
|
||||
accept(i, o, s, NONBLOCKING_INPUT | NONBLOCKING_OUTPUT);
|
||||
w.watch(i, readc, w, i, o, b);
|
||||
}
|
||||
|
||||
integer
|
||||
main(void)
|
||||
{
|
||||
dispatch w;
|
||||
file s;
|
||||
|
||||
tcpip_listen(s, 12321, 0);
|
||||
w.watch(s, serve, w, s);
|
||||
w.press;
|
||||
|
||||
0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue