본문 바로가기

IT

genericClient

// 컴파일 할때 아래의 socklib파일을 함께 해야합니다.


// gcc genericClient.c. socklib.c -o genericClient


#include <stdio.h>

#define LEN 256
#define host "***.***.***.***" // 뭐든 호스트를 입력하세요. 이대로는 안됩니다 ㅋ
#define port 13003

main()
{
    int fd;
    fd = connect_to_server(host, port);
    if (fd == -1)
        exit(1);
    talk_with_server(fd);
    close(fd);
}

talk_with_server(fd)
{
    char buf[LEN];
    int n;

    n = read(fd, buf, LEN);
    write(1, buf, n);
}

'IT' 카테고리의 다른 글

print.c  (0) 2014.12.09
multi.c  (0) 2014.12.09
genericServ.c  (0) 2014.11.23
socklib.c  (0) 2014.11.23
timeserv.c  (0) 2014.11.23