0

So, the code I currently have in C++ is:

#include <SFML/Network.hpp>
#include <iostream>

int main()
{
    // prepare the request
    sf::Http::Request request("/", sf::Http::Request::Get);

    // send the request
    sf::Http http("http://localhost:3000/");
    sf::Http::Response response = http.sendRequest(request);

    // check the status
    std::cout << response.getStatus();

    return 0;
}

And I've created a local server using node.js and I'd like to get the json data. The code above doesn't work and I don't know what to do. The error code I get is 1001 (ConnectionFailed).

Any ideas?

0

1 Answer 1

2

I think you're using the sf::Http constructor wrong.

The constructor calls setHost which does not parse port numbers. You need to explicitly pass the port number as follows:

sf::Http http("http://localhost", 3000);
Sign up to request clarification or add additional context in comments.

1 Comment

Holy, I don't know how I missed that. It seems to be working now, thanks very much!

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.