| 1 | ab11 | 1.1 | #include <sockinet.h> | 
 
 
 
 
 | 2 |  |  | #include <stdlib.h> | 
 
 
 
 
 | 3 |  |  |  | 
 
 
 
 
 | 4 |  |  | static int send_cmd(const char*, iosockstream&); | 
 
 
 
 
 | 5 |  |  | static int get_text(istream&); | 
 
 
 
 
 | 6 |  |  |  | 
 
 
 
 
 | 7 |  |  | int main() | 
 
 
 
 
 | 8 |  |  | { | 
 
 
 
 
 | 9 |  |  | iosockinet     sio(sockbuf::sock_stream); | 
 
 
 
 
 | 10 |  |  | sio->connect("murdoch.acc.virginia.edu", "nntp", "tcp"); | 
 
 
 
 
 | 11 |  |  |  | 
 
 
 
 
 | 12 |  |  | send_cmd(0, sio); | 
 
 
 
 
 | 13 |  |  |  | 
 
 
 
 
 | 14 |  |  | send_cmd("HELP", sio); get_text(sio); | 
 
 
 
 
 | 15 |  |  | send_cmd("QUIT", sio); | 
 
 
 
 
 | 16 |  |  |  | 
 
 
 
 
 | 17 |  |  | return 0; | 
 
 
 
 
 | 18 |  |  | } | 
 
 
 
 
 | 19 |  |  |  | 
 
 
 
 
 | 20 |  |  | int send_cmd(const char* cmd, iosockstream& s) | 
 
 
 
 
 | 21 |  |  | { | 
 
 
 
 
 | 22 |  |  | if (cmd) s << cmd << "\r\n" << flush; | 
 
 
 
 
 | 23 |  |  |  | 
 
 
 
 
 | 24 |  |  | char buf[256]; | 
 
 
 
 
 | 25 |  |  | s.getline(buf, 255); | 
 
 
 
 
 | 26 |  |  |  | 
 
 
 
 
 | 27 |  |  | cout << buf << endl; | 
 
 
 
 
 | 28 |  |  |  | 
 
 
 
 
 | 29 |  |  | if (buf[0] == '4' || buf[1] == '5') return 1; | 
 
 
 
 
 | 30 |  |  | return 0; | 
 
 
 
 
 | 31 |  |  | } | 
 
 
 
 
 | 32 |  |  |  | 
 
 
 
 
 | 33 |  |  | int get_text(istream& s) | 
 
 
 
 
 | 34 |  |  | { | 
 
 
 
 
 | 35 |  |  | char buf[256]; | 
 
 
 
 
 | 36 |  |  | while (s.getline(buf, 255)) | 
 
 
 
 
 | 37 |  |  | if (buf[0] == '.') { | 
 
 
 
 
 | 38 |  |  | if (buf[1] == '.') cout << buf+1 << endl; | 
 
 
 
 
 | 39 |  |  | else return 0; | 
 
 
 
 
 | 40 |  |  | }else | 
 
 
 
 
 | 41 |  |  | cout << buf << endl; | 
 
 
 
 
 | 42 |  |  | return 1; | 
 
 
 
 
 | 43 |  |  | } | 
 
 
 
 
 | 44 |  |  |  |