tnntp.c
来自「《CODE READING》配套书源代码 《CODE READING》配套书源」· C语言 代码 · 共 54 行
C
54 行
// Copyright (C) 1992-1996 Gnanasekaran Swaminathan <gs4t@virginia.edu>//// Permission is granted to use at your own risk and distribute this software// in source and binary forms provided the above copyright notice and this// paragraph are preserved on all copies. This software is provided "as is"// with no express or implied warranty.//// Version: 12Jan97 1.11#include <sockinet.h>#include <stdlib.h>static int send_cmd(const char*, iosockstream&);static int get_text(istream&);int main(){ iosockinet sio(sockbuf::sock_stream); sio->connect("murdoch.acc.virginia.edu", "nntp", "tcp"); send_cmd(0, sio); send_cmd("HELP", sio); get_text(sio); send_cmd("QUIT", sio); return 0;}int send_cmd(const char* cmd, iosockstream& s){ if (cmd) s << cmd << "\r\n" << flush; char buf[256]; s.getline(buf, 255); cout << buf << endl; if (buf[0] == '4' || buf[1] == '5') return 1; return 0;}int get_text(istream& s){ char buf[256]; while (s.getline(buf, 255)) if (buf[0] == '.') { if (buf[1] == '.') cout << buf+1 << endl; else return 0; }else cout << buf << endl; return 1;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?