equal
deleted
inserted
replaced
13 #include <arpa/inet.h> |
13 #include <arpa/inet.h> |
14 |
14 |
15 int connection (char *ip, unsigned short port) |
15 int connection (char *ip, unsigned short port) |
16 { |
16 { |
17 struct hostent *hs; |
17 struct hostent *hs; |
|
18 |
18 struct sockaddr_in sock; |
19 struct sockaddr_in sock; |
|
20 |
19 int sockfd; |
21 int sockfd; |
20 |
22 |
21 memset (&sock, 0, sizeof (sock)); |
23 memset (&sock, 0, sizeof (sock)); |
22 sock.sin_family = AF_INET; |
24 sock.sin_family = AF_INET; |
23 sock.sin_port = htons (port); |
25 sock.sin_port = htons (port); |
45 } |
47 } |
46 |
48 |
47 int main (int argc, char **argv) |
49 int main (int argc, char **argv) |
48 { |
50 { |
49 char buffer[1024]; |
51 char buffer[1024]; |
|
52 |
50 int sockfd; |
53 int sockfd; |
|
54 |
51 int num; |
55 int num; |
52 |
56 |
53 if (argc != 3) { |
57 if (argc != 3) { |
54 printf ("Usage: %s <ipaddr> <port>\n", argv[0]); |
58 printf ("Usage: %s <ipaddr> <port>\n", argv[0]); |
55 return EXIT_SUCCESS; |
59 return EXIT_SUCCESS; |