⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 httpclient.cpp

📁 一个简单实用的开源C++消息中间件SAFMQ - [软件开发] - [开源 消息中间件 SAFMQ ] 2006-11-23 在很多网络应用中
💻 CPP
字号:
/* Copyright 2005 Matthew J. Battey   Licensed under the Apache License, Version 2.0 (the "License");   you may not use this file except in compliance with the License.   You may obtain a copy of the License at       http://www.apache.org/licenses/LICENSE-2.0This software implements a platform independent C++ interface to TCP/IP socketcommunications.*/#include <iostream>#include <string>#include "../socstream.h"#include "../tcpsocket.cpp" // include the source for the socket, typically this compiled seperatelyusing namespace std;using namespace tcpsocket;int main (int argc, char* argv[]){	try {		char* addr;		string	line;		// Determine what address to connect to		if (argc > 1)			addr = argv[1];		else			addr = "www.google.com";		// construct a socstream, and specify the address to connect to		socstream	s(addr,80);		// Send a HTTP 1.0 request for the root resource		s << "GET / HTTP/1.0\n\n" << flush;			// Read the results until the connection is closed			getline(s,line);			while (s.good()) {			// write a line out to the console			cout << line << endl;			getline(s,line);		}		} catch (SocketException& e) {		// Write any errors that might have occured		cout << e.what() << endl;	}	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -