--#-- Who's the host? --#-- One last function and we're through with this module. I'm going to design this program to accept the host and port on the command line like this: hostname:port. We need a function to parse the values out into variables and we might as well put in this file.

If no port is specified, we'll assume it's port 80, the standard Web server port.

char *getHost(char *host, int *port, char *arg) { char *p; p = (char *)strtok(arg, ":"); if (p == NULL) { *port = 80; } strcpy(host, p); p = (char *)strtok(NULL, " "); if (p) *port = atoi(p) return host; }
Put these functions in a file called request.c and see if it compiles. If not, call me.