tcp_connect()The C function tcp_connect() is used by C clients to connect to some
server running on machine host at some port. It returns the newly
created socket. The following program fragment demonstrates the use of the C
function tcp_connect() along with its companion C function
tcp_address_from_file():
#include "tcp.h"
int c,port;
char *host;
if(tcp_address_from_file(serverfile, &port, &host) != 0)
... an error occurred.
c = tcp_connect(host, port);
if (c == -1) ... an error occurred.
A fuller example of the above can be found in the demonstration program cs.c.