There are several support functions for using the networked functions generated by NCG. They connect and disconnect from servers.
The functions are:
SERVER *openserver(char *host,char *port);
SERVER *closeserver(SERVER *se);
int serveruser(char *username);
int serverpass(char *password);
closeserver() functions connect and
disconnect a client to and from a server respectively.
openserver() takes the name of the host and port to connect to.
The host may be a symbolic name like "thunder.thunderstone.com" or a
number like "220.127.116.11". If an empty string or
pointer is passed, "localhost" will be used. Localhost means the same
machine that the client is running on.
The port may be a symbolic name, that has been added to the list of known TCP/IP services on your system, or a number.
openserver() will immediately attempt to connect to the named
host and port. It will return a
SERVER pointer to be passed to
all of the network functions. It will return
SERVERPN on failure
closeserver() will shutdown the connection made by a successful
serverpass() calls set the name and
password, respectively, that
openserver() will use when logging
into the server. Either function will return zero on error. Non-zero is
returned on success.
The default user name and password are both the empty string (
puts("can't open server, exiting.");