Communication between processes is effected through sockets. Sockets are referred to by small 32 bit integers, called file descriptors below (even though they are proper file descriptors only under UNIX).
The program using this package should be linked with the object file
tcp_c.o
(substitute the actual object file extension for .o
).
The sources to create this file, the C source files tcp.c
and tcp.h
, are provided in the tcp library directory.1 Furthermore, the source file tcp.h
from IPC/TCP
should be included in the C sources using the package.
Errors from using the C tcp package are written to stderr
using the
system function perror(3)
, so whenever a tcp C function
indicates an error, the error message has already been printed and
errno has already been set.
Although sockets may be used like any other file descriptor, they must
be killed using tcp_shutdown()
, otherwise the behavior of
tcp_select()
will become unpredictable.
For a C client calling a Prolog server, see example cs.c
(ipc-tcp-exa).
For a Prolog client calling a C server, see example c_server.pl, c_server.c
(ipc-tcp-exa).