/* paul.c */ // This code is provided "as is" with NO WARRANTY expressed or // implied. You may use it freely at your own risk. #include extern char *getHost(char *hostName, int *portNum, char *arg); extern void die(char *s); extern int openSocket(char *host, int port); extern char *formRequest(); extern int writeToSocket(int sock, char *request); extern void printServerResponse(int socket); int main(int argc, char *argv[]) { char hostName[128]; int portNum = 80; int sock, result; char *request; if (argc < 2) { die("Usage: paul hostname:port"); } getHost(hostName, &portNum, argv[1]); request = formRequest(); if ((sock = openSocket(hostName, portNum)) < 0) die("Can't open socket"); result = writeToSocket(sock, request); if (result < 0) die("Server barfed on request"); printServerResponse(sock); free(request); return 0; }