forked from unpbook/unpv13e
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tcpcli01.lc
24 lines (17 loc) · 1.08 KB
/
tcpcli01.lc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "unp.h"## 1 ##src/tcpcliserv/tcpcli01.c##
int## 2 ##src/tcpcliserv/tcpcli01.c##
main(int argc, char **argv)## 3 ##src/tcpcliserv/tcpcli01.c##
{## 4 ##src/tcpcliserv/tcpcli01.c##
int sockfd;## 5 ##src/tcpcliserv/tcpcli01.c##
struct sockaddr_in servaddr;## 6 ##src/tcpcliserv/tcpcli01.c##
if (argc != 2)## 7 ##src/tcpcliserv/tcpcli01.c##
err_quit("usage: tcpcli <IPaddress>");## 8 ##src/tcpcliserv/tcpcli01.c##
sockfd = Socket(AF_INET, SOCK_STREAM, 0);## 9 ##src/tcpcliserv/tcpcli01.c##
bzero(&servaddr, sizeof(servaddr));## 10 ##src/tcpcliserv/tcpcli01.c##
servaddr.sin_family = AF_INET;## 11 ##src/tcpcliserv/tcpcli01.c##
servaddr.sin_port = htons(SERV_PORT);## 12 ##src/tcpcliserv/tcpcli01.c##
Inet_pton(AF_INET, argv[1], &servaddr.sin_addr);## 13 ##src/tcpcliserv/tcpcli01.c##
Connect(sockfd, (SA *) &servaddr, sizeof(servaddr));## 14 ##src/tcpcliserv/tcpcli01.c##
str_cli(stdin, sockfd); /* do it all */## 15 ##src/tcpcliserv/tcpcli01.c##
exit(0);## 16 ##src/tcpcliserv/tcpcli01.c##
}## 17 ##src/tcpcliserv/tcpcli01.c##