I use C++ REST SDK to build up a HTTP server which is used for receiving requests from postman, but if I code like this:
http_listener listener(L"http://localhost/io");
listener.open().wait();
listener.support(methods::POST, [](http_request req) {
});
Postman can connect to it with http://localhost/io
in POST method,
But if I code like :
http_listener listener(L"http://localhost:6000/io");
Postman cannot connect to it with http://localhost:6000/io
and POST method.
But if I code like http_listener listener(L"http://localhost/io:6000");
Postman can connect with it in http://localhost/io:6000
with POST method. How could I make http://localhost:6000/io
works for my listener ? Another program I work with always send http request to http://localhost:6000/io
, so I need to let my server listen on this address.
http_listener listener(L"http://localhost:6000"); //doesn't work, too.
But when I change 6000 to any other port num,like 7000 or 8000, like http_listener listener(L"http://localhost:7000")
or http_listener listener(L"http://localhost:7000/io")
it works for me. I use netstat -a -b
to check whether 6000 has been occupied by another program, but 6000 is free.