Makefile でのコンパイルコマンド(正確にはリンクコマンド) にオプション -lz を付けること

#include "network.h"
#include "http_tool.h"

#define BUFLEN 1024


int main(int argc, char** argv)
{
    int  sock, cc, len;
    char buf[BUFLEN];
    tList* lp = NULL;

    if (argc<2) {
        fprintf(stderr, "Usage.....  %s URL\n", argv[0]);
        exit(1);
    }

    sock = tcp_client_socket(argv[1], 80);
    if (sock<=0) {
        fprintf(stderr, "Can not connect to %s\n", argv[1]);
        exit(1);
    }

    tcp_send_mesg(sock, "GET / HTTP/1.0\r\n\r\n");

    cc = recv_http_header(sock, &lp, &len, NULL, NULL);
    print_tList(stdout, lp);
    printf("\n-------------------------------\n");

    while(cc>0) {
        memset(buf, 0, BUFLEN);
        cc = tcp_recv_wait(sock, buf, BUFLEN, 10);
        if (cc>0) printf("%s", buf);
    }

    close(sock);
}
Last modified: Thursday, 25 June 2015, 11:08 PM