CS11 CS8-6D CS17操作机构雾霾当前中外有何不同同?请详解

联系人:付友成 &nbsp
公司名称:
CS11 CS8-6D CS17 手动机构 GW4 GW5 GW8隔离开关手动操作机构
最近被加入的企业
名片夹还没有企业信息,赶紧查看企业联系方式加入吧!
『上海荣控电气有限公司』的联系方式为,8,联系人:付友成 &nbsp
隔离开关优质精品供应商推荐
品牌:高耀
型号: GW4-40.5
安装地点:户外
绝缘支柱结构:三柱式
投切方式:单投式
接地方式:单接地
加工定制:是
额定电压:40.5
工频耐受电压:1250
雷电冲击耐受电压:142
额定电流:
额定峰值耐受电流:
额定短路耐受电流:
额定频率:
额定短时持续时间:
壳体防护等级:
机械寿命:
工作温度范围:
产品认证:
外形尺寸:
认证信息:认证企业
品牌/型号:荣控/CS11 CS8-6D CS17 手动机构 GW4 GW5 GW8型号:CS11 CS8-6D CS17 手动机构 GW4 GW5 GW8品牌:荣控加工定制:是
以上是CS11 CS8-6D CS17 手动机构 GW4 GW5 GW8隔离开关手动操作机构的详细介绍,包括CS11 CS8-6D CS17 手动机构 GW4 GW5 GW8隔离开关手动操作机构的价格、型号、图片、厂家等信息!
'&荣控电气专业从事高压电气产品生产销售,高压负荷开关、真空断路器、隔离开关、接地开关 、电缆分接箱、高压熔断器、互感器、避雷器、绝缘子、穿墙套管、电磁锁、带电显示装置等系列产品。由于产品型号规格较多,请先咨询再订购,谢谢配合!量...
商机库包括所有采购、招标信息的汇总
与CS11 CS8-6D CS17 手动机构 GW4 GW5 GW8隔离开关手动操作机构相关的产品信息
CS11 CS8-6D CS17 手动机构 GW4 GW5 GW8隔离开关手动操作机构产品相关搜索
最新其他高压电器产品
按排行字母分类:
*联系电话:
*短信验证:
允许同品类其他优质供应商联系我httprequest - How do you make a HTTP request with C++? - Stack Overflow
Join Stack Overflow to learn, share knowledge, and build your career.
or sign in with
Is there any way to easily make a HTTP request with C++?
Specifically, I want to download the contents of a page (an API) and check the contents to see if it contains a 1 or a 0. Is it also possible to download the contents into a string?
112k15137189
11.4k134872
I had the same problem.
is really complete. There is a C++ wrapper
that might interest you as you ask for a C++ library.
is another interesting C library that also support webdav.
curlpp seems natural if you use C++. There are many examples provided in the source distribution.
To get the content of an URL you do something like that (extracted from examples) :
// Edit : rewritten for cURLpp 0.7.3
// Note : namespace changed, was cURLpp in 0.7.2 ...
#include &curlpp/cURLpp.hpp&
#include &curlpp/Options.hpp&
// RAII cleanup
curlpp::Cleanup myC
// Send request and get a result.
// Here I use a shortcut to get it in a string stream ...
os && curlpp::options::Url(std::string("http://www.wikipedia.org"));
string asAskedInQuestion = os.str();
See the examples directory in , there is a lot of more complex cases.
my 2 cents ...
Windows code:
#include &string.h&
#include &winsock2.h&
#include &windows.h&
#include &iostream&
#include &vector&
#include &locale&
#include &sstream&
#pragma comment(lib,"ws2_32.lib")
int main( void ){
WSADATA wsaD
SOCKADDR_IN SockA
int lineCount=0;
int rowCount=0;
struct hostent *
char buffer[10000];
int i = 0 ;
int nDataL
string website_HTML;
// website url
string url = "www.google.com";
//HTTP GET
string get_http = "GET / HTTP/1.1\r\nHost: " + url + "\r\nConnection: close\r\n\r\n";
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0){
cout && "WSAStartup failed.\n";
system("pause");
//return 1;
Socket=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
host = gethostbyname(url.c_str());
SockAddr.sin_port=htons(80);
SockAddr.sin_family=AF_INET;
SockAddr.sin_addr.s_addr = *((unsigned long*)host-&h_addr);
if(connect(Socket,(SOCKADDR*)(&SockAddr),sizeof(SockAddr)) != 0){
cout && "Could not connect";
system("pause");
//return 1;
// send GET / HTTP
send(Socket,get_http.c_str(), strlen(get_http.c_str()),0 );
// recieve html
while ((nDataLength = recv(Socket,buffer,10000,0)) & 0){
int i = 0;
while (buffer[i] &= 32 || buffer[i] == '\n' || buffer[i] == '\r'){
website_HTML+=buffer[i];
closesocket(Socket);
WSACleanup();
// Display HTML source
cout&&website_HTML;
cout&&"\n\nPress ANY key to close.\n\n";
cin.ignore(); cin.get();
Here is a much better implementation:
#include &windows.h&
#include &string&
#include &stdio.h&
using std::
#pragma comment(lib,"ws2_32.lib")
HINSTANCE hI
WSADATA wsaD
void mParseUrl(char *mUrl, string &serverName, string &filepath, string &filename);
SOCKET connectToServer(char *szServerName, WORD portNum);
int getHeaderLength(char *content);
char *readUrl2(char *szUrl, long &bytesReturnedOut, char **headerOut);
int main()
const int bufLen = 1024;
char *szUrl = "http://stackoverflow.com";
long fileS
char *memBuffer, *headerB
memBuffer = headerBuffer = NULL;
if ( WSAStartup(0x101, &wsaData) != 0)
return -1;
memBuffer = readUrl2(szUrl, fileSize, &headerBuffer);
printf("returned from readUrl\n");
printf("data returned:\n%s", memBuffer);
if (fileSize != 0)
printf("Got some data\n");
fp = fopen("downloaded.file", "wb");
fwrite(memBuffer, 1, fileSize, fp);
fclose(fp);
delete(memBuffer);
delete(headerBuffer);
WSACleanup();
void mParseUrl(char *mUrl, string &serverName, string &filepath, string &filename)
string::size_
string url = mU
if (url.substr(0,7) == "http://")
url.erase(0,7);
if (url.substr(0,8) == "https://")
url.erase(0,8);
n = url.find('/');
if (n != string::npos)
serverName = url.substr(0,n);
filepath = url.substr(n);
n = filepath.rfind('/');
filename = filepath.substr(n+1);
serverName =
filepath = "/";
filename = "";
SOCKET connectToServer(char *szServerName, WORD portNum)
struct hostent *
struct sockaddr_
conn = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (conn == INVALID_SOCKET)
return NULL;
if(inet_addr(szServerName)==INADDR_NONE)
hp=gethostbyname(szServerName);
addr=inet_addr(szServerName);
hp=gethostbyaddr((char*)&addr,sizeof(addr),AF_INET);
if(hp==NULL)
closesocket(conn);
return NULL;
server.sin_addr.s_addr=*((unsigned long*)hp-&h_addr);
server.sin_family=AF_INET;
server.sin_port=htons(portNum);
if(connect(conn,(struct sockaddr*)&server,sizeof(server)))
closesocket(conn);
return NULL;
int getHeaderLength(char *content)
const char *srchStr1 = "\r\n\r\n", *srchStr2 = "\n\r\n\r";
char *findP
int ofset = -1;
findPos = strstr(content, srchStr1);
if (findPos != NULL)
ofset = findPos -
ofset += strlen(srchStr1);
findPos = strstr(content, srchStr2);
if (findPos != NULL)
ofset = findPos -
ofset += strlen(srchStr2);
char *readUrl2(char *szUrl, long &bytesReturnedOut, char **headerOut)
const int bufSize = 512;
char readBuffer[bufSize], sendBuffer[bufSize], tmpBuffer[bufSize];
char *tmpResult=NULL, *
string server, filepath,
long totalBytesRead, thisReadSize, headerL
mParseUrl(szUrl, server, filepath, filename);
///////////// step 1, connect //////////////////////
conn = connectToServer((char*)server.c_str(), 80);
///////////// step 2, send GET request /////////////
sprintf(tmpBuffer, "GET %s HTTP/1.0", filepath.c_str());
strcpy(sendBuffer, tmpBuffer);
strcat(sendBuffer, "\r\n");
sprintf(tmpBuffer, "Host: %s", server.c_str());
strcat(sendBuffer, tmpBuffer);
strcat(sendBuffer, "\r\n");
strcat(sendBuffer, "\r\n");
send(conn, sendBuffer, strlen(sendBuffer), 0);
SetWindowText(edit3Hwnd, sendBuffer);
printf("Buffer being sent:\n%s", sendBuffer);
///////////// step 3 - get received bytes ////////////////
// Receive until the peer closes the connection
totalBytesRead = 0;
memset(readBuffer, 0, bufSize);
thisReadSize = recv (conn, readBuffer, bufSize, 0);
if ( thisReadSize &= 0 )
tmpResult = (char*)realloc(tmpResult, thisReadSize+totalBytesRead);
memcpy(tmpResult+totalBytesRead, readBuffer, thisReadSize);
totalBytesRead += thisReadS
headerLen = getHeaderLength(tmpResult);
long contenLen = totalBytesRead-headerL
result = new char[contenLen+1];
memcpy(result, tmpResult+headerLen, contenLen);
result[contenLen] = 0x0;
myTmp = new char[headerLen+1];
strncpy(myTmp, tmpResult, headerLen);
myTmp[headerLen] = NULL;
delete(tmpResult);
*headerOut = myT
bytesReturnedOut = contenL
closesocket(conn);
return(result);
6,22621521
On Linux, I tried cpp-netlib, libcurl, curlpp, urdl, boost::asio and considered Qt (but turned it down based on the license). All of these were either incomplete for this use, had sloppy interfaces, had poor documentation, were unmaintained or didn't support https.
Then, at the suggestion of , I tried POCO. Wow, I wish I had seen this years ago. Here's an example of making an HTTP GET request:
POCO is free, open source (boost license). And no, I don't have any affiliat I just really like their interfaces. Great job guys (and gals).
Hope this helps someone... it took me three days to try all of these libraries out.
9,06484365
There is a newer, less mature curl wrapper being developed called . Here's a simple GET request:
#include &iostream&
#include &cpr.h&
int main(int argc, char** argv) {
auto response = cpr::Get(cpr::Url{"http://httpbin.org/get"});
std::cout && response.text && std::
It supports a wide variety of HTTP verbs and curl options. There's more usage documentation .
Disclaimer: I'm the maintainer of this library.
As you want a C++ solution, you could use . It has a QHttp class you can use.
You can check the :
http-&setHost("qt.nokia.com");
http-&get(QUrl::toPercentEncoding("/index.html"));
Qt also has a lot more to it that you could use in a common C++ app.
19.4k21020
is a pretty good option for you. Depending on what you need to do, the
should tell you what you want, specifically for the easy handle. But, basically, you could do this just to see the source of a page:
c = curl_easy_init();
curl_easy_setopt( c, CURL_URL, "www.google.com" );
curl_easy_perform( c );
curl_easy_cleanup( c );
I believe this will cause the result to be printed to stdout. If you want to handle it instead -- which, I assume, you do -- you need to set the CURL_WRITEFUNCTION. All of that is covered in the curl tutorial linked above.
6,59142841
Here is my minimal wrapper around cURL to be able just to fetch a webpage as a string. This is useful, for example, for unit testing.
It is basically a RAII wrapper around the C code.
Install "libcurl" on your machine yum install libcurl libcurl-devel or equivalent.
Usage example:
string x = client.Get("http://google.com");
string y = client.Get("http://yahoo.com");
Class implementation:
#include &curl/curl.h&
class CURLplusplus
long http_
CURLplusplus()
: curl(curl_easy_init())
, http_code(0)
~CURLplusplus()
if (curl) curl_easy_cleanup(curl);
std::string Get(const std::string& url)
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, this);
ss.str("");
http_code = 0;
res = curl_easy_perform(curl);
if (res != CURLE_OK)
throw std::runtime_error(curl_easy_strerror(res));
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
return ss.str();
long GetHttpCode()
return http_
static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp)
return static_cast&CURLplusplus*&(userp)-&Write(buffer,size,nmemb);
size_t Write(void *buffer, size_t size, size_t nmemb)
ss.write((const char*)buffer,size*nmemb);
return size*
With this answer I refer to the . By rebuilding the code I found that some parts are deprecated (gethostbyname()) or do not provide error handling (creation of sockets, sending something) for an operation.
The following windows code is tested with Visual Studio 2013 and Windows 8.1 64-bit as well as Windows 7 64-bit. It will target an IPv4 TCP Connection with the Web Server of www.google.com.
#include &winsock2.h&
#include &WS2tcpip.h&
#include &windows.h&
#include &iostream&
#pragma comment(lib,"ws2_32.lib")
int main (){
// Initialize Dependencies to the Windows Socket.
WSADATA wsaD
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
cout && "WSAStartup failed.\n";
system("pause");
return -1;
// We first prepare some "hints" for the "getaddrinfo" function
// to tell it, that we are looking for a IPv4 TCP Connection.
ZeroMemory(&hints, sizeof(hints));
hints.ai_family = AF_INET;
// We are targeting IPv4
hints.ai_protocol = IPPROTO_TCP;
// We are targeting TCP
hints.ai_socktype = SOCK_STREAM;
// We are targeting TCP so its SOCK_STREAM
// Aquiring of the IPv4 address of a host using the newer
// "getaddrinfo" function which outdated "gethostbyname".
// It will search for IPv4 addresses using the TCP-Protocol.
struct addrinfo* targetAdressInfo = NULL;
DWORD getAddrRes = getaddrinfo("www.google.com", NULL, &hints, &targetAdressInfo);
if (getAddrRes != 0 || targetAdressInfo == NULL)
cout && "Could not resolve the Host Name" &&
system("pause");
WSACleanup();
return -1;
// Create the Socket Address Informations, using IPv4
// We dont have to take care of sin_zero, it is only used to extend the length of SOCKADDR_IN to the size of SOCKADDR
SOCKADDR_IN sockA
sockAddr.sin_addr = ((struct sockaddr_in*) targetAdressInfo-&ai_addr)-&sin_
// The IPv4 Address from the Address Resolution Result
sockAddr.sin_family = AF_INET;
sockAddr.sin_port = htons(80);
// HTTP Port: 80
// We have to free the Address-Information from getaddrinfo again
freeaddrinfo(targetAdressInfo);
// Creation of a socket for the communication with the Web Server,
// using IPv4 and the TCP-Protocol
SOCKET webSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (webSocket == INVALID_SOCKET)
cout && "Creation of the Socket Failed" &&
system("pause");
WSACleanup();
return -1;
// Establishing a connection to the web Socket
cout && "Connecting...\n";
if(connect(webSocket, (SOCKADDR*)&sockAddr, sizeof(sockAddr)) != 0)
cout && "Could not connect";
system("pause");
closesocket(webSocket);
WSACleanup();
return -1;
cout && "Connected.\n";
// Sending a HTTP-GET-Request to the Web Server
const char* httpRequest = "GET / HTTP/1.1\r\nHost: www.google.com\r\nConnection: close\r\n\r\n";
int sentBytes = send(webSocket, httpRequest, strlen(httpRequest),0);
if (sentBytes & strlen(httpRequest) || sentBytes == SOCKET_ERROR)
cout && "Could not send the request to the Server" &&
system("pause");
closesocket(webSocket);
WSACleanup();
return -1;
// Receiving and Displaying an answer from the Web Server
char buffer[10000];
ZeroMemory(buffer, sizeof(buffer));
while ((dataLen = recv(webSocket, buffer, sizeof(buffer), 0) & 0))
int i = 0;
while (buffer[i] &= 32 || buffer[i] == '\n' || buffer[i] == '\r') {
cout && buffer[i];
// Cleaning up Windows Socket Dependencies
closesocket(webSocket);
WSACleanup();
system("pause");
References:
1,16621737
You may want to check
(codename "Casablanca").
With the C++ REST SDK, you can more easily connect to HTTP servers from your C++ app.
Usage example:
#include &iostream&
#include &cpprest/http_client.h&
using namespace web::
// Common HTTP functionality
using namespace web::http::
// HTTP client features
int main(int argc, char** argv) {
http_client client("http://httpbin.org/");
// ordinary `get` request
response = client.request(methods::GET, "/get").get();
std::cout && response.extract_string().get() && "\n";
// working with json
response = client.request(methods::GET, "/get").get();
std::cout && "url: " && response.extract_json().get()[U("url")] && "\n";
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design.
4,11523360
C++ does not provide any way to do it directly. It would entirely depend on what platforms and libraries that you have.
At worst case, you can use the boost::asio library to establish a TCP connection, send the HTTP headers (RFC 2616), and parse the responses directly. Looking at your application needs, this is simple enough to do.
You can use
library. It is lightweight header-only library. So it is easy to include it to your project and it does not require compilation cause there no .cpp files in it.
Request example from readme.md from repo:
#include "UrlRequest.hpp"
request.host("api.vk.com");
const auto countryId=1;
const auto count=1000;
request.uri("/method/database.getCities",{
{"lang","ru"},
{"country_id",countryId},
{"count",count},
{"need_all","1"},
request.addHeader("Content-Type: application/json");
auto response=std::move(request.perform());
if(response.statusCode()==200){
cout&&"status code = "&&response.statusCode()&&", body = *"&&response.body()&&"*"&&
cout&&"status code = "&&response.statusCode()&&", description = "&&response.statusDescription()&&
1,77511322
C and C++ don't have a standard library for HTTP or even for socket connections. Over the years some portable libraries have been developed. The most widely used, as others have said, is .
of alternatives to libcurl (coming from the libcurl's web site).
Also, for Linux,
is a simple HTTP client. You could implement your own simple HTTP GET client, but this won't work if there are authentication or redirects involved or if you need to work behind a proxy. For these cases you need a full-blown library like libcurl.
For source code with libcurl,
is the closest to what you want (Libcurl has many ). Look at the main function. The html content will be copied to the buffer, after a successfully connection. Just replace parseHtml with your own function.
84k18138182
Here is some (relatively) simple C++11 code that uses libCURL to download a URL's content into a std::vector&char&:
http_download.hh
# pragma once
#include &string&
#include &vector&
std::vector&char& download(std::string url, long* responseCode = nullptr);
http_download.cc
#include "http_download.hh"
#include &curl/curl.h&
#include &sstream&
#include &stdexcept&
size_t callback(void* contents, size_t size, size_t nmemb, void* user)
auto chunk = reinterpret_cast&char*&(contents);
auto buffer = reinterpret_cast&vector&char&*&(user);
size_t priorSize = buffer-&size();
size_t sizeIncrease = size *
buffer-&resize(priorSize + sizeIncrease);
std::copy(chunk, chunk + sizeIncrease, buffer-&data() + priorSize);
return sizeI
vector&char& download(string url, long* responseCode)
vector&char&
curl_global_init(CURL_GLOBAL_ALL);
CURL* handle = curl_easy_init();
curl_easy_setopt(handle, CURLOPT_URL, url.c_str());
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, callback);
curl_easy_setopt(handle, CURLOPT_WRITEDATA, &data);
curl_easy_setopt(handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
CURLcode result = curl_easy_perform(handle);
if (responseCode != nullptr)
curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, responseCode);
curl_easy_cleanup(handle);
curl_global_cleanup();
if (result != CURLE_OK)
err && "Error downloading from URL \"" && url && "\": " && curl_easy_strerror(result);
throw runtime_error(err.str());
return move(data);
166k97491574
Generally I'd recommend something cross-platform like cURL, POCO, or Qt. However, here is a Windows example!:
#include &atlbase.h&
#include &msxml6.h&
#include &comutil.h& // _bstr_t
CComPtr&IXMLHTTPRequest&
hr = request.CoCreateInstance(CLSID_XMLHTTP60);
hr = request-&open(
_bstr_t("GET"),
_bstr_t("https://www.google.com/images/srpr/logo11w.png"),
_variant_t(VARIANT_FALSE),
_variant_t(),
_variant_t());
hr = request-&send(_variant_t());
// get status - 200 if succuss
hr = request-&get_status(&status);
// load image data (if url points to an image)
VARIANT responseV
hr = request-&get_responseStream(&responseVariant);
IStream* stream = (IStream*)responseVariant.punkV
CImage *image = new CImage();
image-&Load(stream);
stream-&Release();
4,94554497
8,14914338
The HTTP protocol is very simple, so it is very simple to write a HTTP client.
Here is one
It uses HTTP GET to retrieve a file from a web server, both server and file are command line parameters. The remote file is saved to a local copy.
Disclaimer: I am the author
EDIT: edited URL
Although a little bit late. You may prefer
It allows you to do http call on mobile c++ development. Suitable for Mobile game developement
bcl::init(); // init when using
bcl::execute&std::string&([&](bcl::Request *req) {
bcl::setOpts(req, CURLOPT_URL , "http://www.google.com",
CURLOPT_FOLLOWLOCATION, 1L,
CURLOPT_WRITEFUNCTION, &bcl::writeContentCallback,
CURLOPT_WRITEDATA, req-&dataPtr,
CURLOPT_USERAGENT, "libcurl-agent/1.0",
CURLOPT_RANGE, "0-200000"
}, [&](bcl::Response * resp) {
std::string ret =
std::string(resp-&getBody&std::string&()-&c_str());
printf("Sync === %s\n", ret.c_str());
bcl::cleanUp(); // clean up when no more using
You can use ACE in order to do so:
#include "ace/SOCK_Connector.h"
int main(int argc, ACE_TCHAR* argv[])
//HTTP Request Header
char* szRequest = "GET /video/nice.mp4 HTTP/1.1\r\nHost: example.com\r\n\r\n";
int ilen = strlen(szRequest);
//our buffer
char output[16*1024];
ACE_INET_Addr server (80, "example.com");
ACE_SOCK_S
ACE_SOCK_C
int ires = connector.connect(peer, server);
int sum = 0;
peer.send(szRequest, ilen);
while (true)
ACE_Time_Value timeout = ACE_Time_Value(15);
int rc = peer.recv_n(output, 16*1024, &timeout);
if (rc == -1)
peer.close();
printf("Bytes transffered: %d",sum);
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Upcoming Events
Stack Overflow works best with JavaScript enabled}

我要回帖

更多关于 除夜作与元日有何不同 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信