/usr/share/gap/pkg/io/example/clientTCP.g is in gap-io 4.5.1+ds-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | # A little network client using TCP/IP:
LoadPackage("io");
Print("Connecting via TCP/IP...\n");
s := IO_socket(IO.PF_INET,IO.SOCK_STREAM,"tcp");
res := IO_connect(s,IO_MakeIPAddressPort("127.0.0.1",8000));
if res = fail then
Print("Error: ",LastSystemError(),"\n");
IO_close(s);
else
f := IO_WrapFD(s,IO.DefaultBufSize,IO.DefaultBufSize);
IO_WriteLine(f,"Hello world!\n");
Print("Sent: Hello word!\n");
st := IO_ReadLine(f);
Print("Got back: ",st);
IO_Close(f);
fi;
s := IO_socket(IO.PF_INET,IO.SOCK_STREAM,"tcp");
res := IO_connect(s,IO_MakeIPAddressPort("127.0.0.1",8000));
if res = fail then
Print("Error: ",LastSystemError(),"\n");
IO_close(s);
else
f := IO_WrapFD(s,IO.DefaultBufSize,IO.DefaultBufSize);
IO_WriteLine(f,"QUIT\n");
Print("Sent: QUIT\n");
st := IO_ReadLine(f);
Print("Got back: ",st);
IO_Close(f);
fi;
|