1 |
#include <sockinet.h> |
2 |
|
3 |
int main(int ac, char** av) |
4 |
{ |
5 |
if (ac != 2 && ac != 3) { |
6 |
cerr << "USAGE: " << av[0] << " [ -l ] user_name\n"; |
7 |
return 1; |
8 |
} |
9 |
|
10 |
iosockinet sio (sockbuf::sock_stream); |
11 |
|
12 |
if (ac == 3) { |
13 |
if (av[1][0] != '-' || av[1][1] != 'l') { |
14 |
cerr << "USAGE: " << av[0] << " [ -l ] user_name\n"; |
15 |
return 1; |
16 |
} |
17 |
// use local whois server |
18 |
sio->connect ("128.143.2.20", "whois", "tcp"); |
19 |
sio << av[2] << "\r\n" << flush; |
20 |
} else { |
21 |
sio->connect ("nic.ddn.mil", "whois", "tcp"); |
22 |
sio << av[1] << "\r\n" << flush; |
23 |
} |
24 |
|
25 |
char buf[1024]; |
26 |
while ( sio.getline(buf, 1023) ) cout << buf << endl; |
27 |
cout << endl; |
28 |
|
29 |
return 0; |
30 |
} |