使用C ++的简单HTTP请求 [英] Simple HTTP request with C++

查看:113
本文介绍了使用C ++的简单HTTP请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在标记这个冗余之前,知道我已经尝试了很多的方法贴在网络(堆栈溢出包括)已经和他们都不能满足我的需要。另外请注意,我是一个新的编程世界,所以请原谅我滥用技术术语。

Before you flag this for redundancy, do know that I have tried a lot of the methods posted around the web (stack overflow included) already and they each couldn't satisfy my needs. Also do note I am quite new to the programming world so excuse me for my misuse of technical terms.

现在我正在编写一个C ++程序,计算一些数据从用户计算机(例如IP地址),然后将IP地址发送到已设置的服务器。我通过一个URL。因此,例如,如果服务器位于 http://stack1234abcdz.com ,并且用户的IP地址为100.100.100.100,那么我会请求

Right now I am writing a C++ program that computes some data from the user's computer (IP address for example), then I send the IP address to a server that's already set up. I do this through an URL. So for example, if the server is at http://stack1234abcdz.com, and the user's IP address is 100.100.100.100 , then I would request

http://stack1234abcdz.com/?ip="100.100.100.100

我试过libcurl,它的工作在一定程度上,但在编译后,我需要5 .dll与.exe相同的目录,以运行它,我不能因为我的问题的一些可移植性。

I have tried libcurl and it works to some extent, but after compiling, I require 5 .dll in the same directory as the .exe in order to run it, which I cannot have due to some portability of my problem.

我也尝试过一些其他传统的套接字方法,但他们需要加载的库和SDK,这是硬的配置,他们经常压倒像我这样的新手,我需要做的是非常简单的(我甚至不需要服务器发送任何东西,除了成功或失败的代码),因此我不认为我应该

I have also tried some other traditional socket methods, but they require loads of libraries and SDKs, which are hard to configure and they often overwhelm a newbie like me. What I need to do is very simple (I don't even need the server to send anything back except for maybe success or failure codes), therefore I don't think I should be needing so much to do so little.

我在Windows 7(64位)机器上使用Visual Studio 2006,做C ++,我不能使用较新的版本,因为大多数给我的其他代码是在VS2006,他们不会转移/转换为较新的版本。

I am using Visual Studio 2006 on Windows 7 (64 bit) machine, doing C++. I cannot use newer versions because most of the other code that was given to me is in VS2006 and they do not transfer/convert well to newer versions.

我想我现在要求的是我应该做什么下一个。有没有办法使可执行文件libcurl不使用5 .dll?我看到某个地方,我必须做一些静态链接的东西,但他们不是非常具体。

I guess what I'm asking now is what I should do next. Is there a way to make the executable with libcurl to NOT use 5 .dll? I saw somewhere that I have to do some static linking stuff, but they weren't being very specific.

或者有更简单的方法来解决我的问题,我忽略了? WinInet? CAtlHttpClientT?卡萨布兰卡?我不喜欢安装和配置复杂的库,我还没有抓住我的心,特别是对于我的问题的大小...

Or are there simpler ways to solve my problem that I overlooked? WinInet? CAtlHttpClientT? Casablanca? I'd prefer not to install and configure complex libraries that I have yet to grasp my mind around, especially not for the size of my problem...

我会感激

推荐答案

经过大量的尝试和错误后,我解决了自己的问题。
我在CInternetSession类中使用了OpenURL()函数。
在一个简单的打开大约25行代码。在进入一些问题,包括afxinet.h,stdafx.h,httpClient.h。这个顺序对我有用,但对于其他程序可能不同。

After lots of trials and errors I solved my own problem. I used OpenURL() function in the CInternetSession class. Did a simple open in around 25 lines of code. Ran into some problems while including afxinet.h, stdafx.h, httpClient.h. That order worked for me, but might be different for other programs.

这篇关于使用C ++的简单HTTP请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆