I am using Poco::Net::HTTPServer. I can set the port, but how can I set the listening interface/address? It defaults to 0.0.0.0
Poco::UInt16 port = 4000;
Poco::Net::ServerSocket socket(port);
Poco::Net::HTTPServerParams *pParams = new
Poco::Net::HTTPServerParams();
pParams->setMaxQueued(100);
pParams->setMaxThreads(16);
Poco::Net::HTTPServer server(new HandleFactory(this->licenseServer), socket, pParams);
server.start();
ServerSocket
has a few versions of its constructor, instead of
ServerSocket(Uint16 port, int)
you should use
ServerSocket(
const SocketAddress & address,
int backlog = 64
);
and construct SocketAddress
passing first argument as IP address (it can be string object) and second argument as port:
Poco::UInt16 port = 4000;
Poco::Net::ServerSocket socket(Poco::Net::SocketAddress("0.0.0.0",port));