Hasan
Hasan

Reputation: 1895

Poco HTTPServer

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();

Upvotes: 3

Views: 1629

Answers (1)

rafix07
rafix07

Reputation: 20936

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));

Upvotes: 7

Related Questions