ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/socket++-1.10/test/thostnames.C
Revision: 1.2
Committed: Mon Jun 10 14:10:44 2002 UTC (22 years, 4 months ago) by tdb
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Error occurred while calculating annotation data.
Log Message:
Tidy up of files. These are all old things that are not only no longer used
but are also probably useless to anyone other than us. This saves checking
them out all the time, and makes the "cms/source" tree contain only current
stuff. They'll still exist in the attic's though :)

File Contents

# Content
1 #include <sockinet.h>
2 #include <ctype.h>
3 #include <string.h>
4
5 static void get_text (iosockstream& s);
6
7 int main(int ac, char** av)
8 {
9 if (ac != 2) {
10 cerr << "USAGE: " << av[0] << " hostname\n";
11 return 1;
12 }
13
14 iosockinet sio(sockbuf::sock_stream);
15 sio->connect ("nic.ddn.mil", "hostnames", "tcp");
16
17 sio << "HNAME " << av[1] << "\r\n" << flush;
18 get_text (sio);
19
20 return 0;
21 }
22
23 void get_text(iosockstream& s)
24 {
25 char buf[1024];
26 int tmo = s->recvtimeout(30); // wait for 30 sec before timing out
27
28 if (s.getline (buf, 1023))
29 cout << buf << endl;
30
31 if (strncmp (buf, "BEGIN", 5) == 0)
32 while (s.getline (buf, 1023)) {
33 cout << buf << endl;
34 if (strncmp (buf, "END", 3) == 0) break;
35 }
36 else
37 while (s.getline (buf, 1023)) {
38 cout << buf << endl;
39 if (!isspace (buf [0])) break;
40 }
41 if ( !s->is_eof() ) s.clear();
42 s->recvtimeout(tmo); //reset timeout to the previous value
43 }