8

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.

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

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.

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.

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.

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.

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...

I would appreciate any help/opinion/feedback on this matter, thanks!

8
  • Have you tried this: How do you make a HTTP request with C++?? Commented May 16, 2014 at 4:31
  • 1
    Yes I have looked at that page already. curlpp however is a pain to deal with and I get several errors with missing header files and whatnot every time I try. I have not tried the other APIs mainly because I am exhausted from dealing with configuration (and my success rate with them are usually quite minimal.) Commented May 16, 2014 at 4:39
  • Why don't use posix socket (winsock) to open a tcp connection to port 80, and then send something like GET /?ip="100.100.100.100 HTTP/1.0\r\n\r\n? Opening a socket in C is literally 10 lines of code. Commented May 16, 2014 at 4:52
  • 1
    What about this? stackoverflow.com/questions/22077802/… It isn't exactly the same because he wanted to send it to a different place with different query string but it should be close. Commented May 16, 2014 at 4:54
  • Can't believe I didn't find that question/answer Jerry linked. As for sockets, my superior said I didn't need to get to the "socket" level so I didn't bother, but I guess I'm wrong. Am looking at both right now. Commented May 16, 2014 at 5:04

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

it'd be so helpful if you posted those 25 lines!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.