diff options
Diffstat (limited to 'mnc.c')
-rw-r--r-- | mnc.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -40,8 +40,8 @@ | |||
40 | #define BUFSIZE 100 | 40 | #define BUFSIZE 100 |
41 | 41 | ||
42 | static const char mnc_usage[] = | 42 | static const char mnc_usage[] = |
43 | "mini-netcat 0.0.3 -- Open pipe to IP:port\n" | 43 | "mnc [IP] [port]\n\n" |
44 | "\tmnc [IP] [port]\n"; | 44 | "mini-netcat opens a pipe to IP:port\n"; |
45 | 45 | ||
46 | int | 46 | int |
47 | mnc_main(int argc, char **argv) | 47 | mnc_main(int argc, char **argv) |
@@ -56,9 +56,15 @@ mnc_main(int argc, char **argv) | |||
56 | 56 | ||
57 | fd_set readfds, testfds; | 57 | fd_set readfds, testfds; |
58 | 58 | ||
59 | if (argc<=1 || **(argv+1) == '-' ) { | ||
60 | usage( mnc_usage); | ||
61 | } | ||
62 | argc--; | ||
63 | argv++; | ||
64 | |||
59 | sfd = socket(AF_INET, SOCK_STREAM, 0); | 65 | sfd = socket(AF_INET, SOCK_STREAM, 0); |
60 | 66 | ||
61 | hostinfo = (struct hostent *) gethostbyname(argv[1]); | 67 | hostinfo = (struct hostent *) gethostbyname(*argv); |
62 | 68 | ||
63 | if (!hostinfo) | 69 | if (!hostinfo) |
64 | { | 70 | { |
@@ -67,7 +73,7 @@ mnc_main(int argc, char **argv) | |||
67 | 73 | ||
68 | address.sin_family = AF_INET; | 74 | address.sin_family = AF_INET; |
69 | address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list; | 75 | address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list; |
70 | address.sin_port = htons(atoi(argv[2])); | 76 | address.sin_port = htons(atoi(*(++argv))); |
71 | 77 | ||
72 | len = sizeof(address); | 78 | len = sizeof(address); |
73 | 79 | ||