1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Add the option to bind to a specific address

This commit is contained in:
ShadowNinja 2014-02-05 21:24:46 +01:00 committed by sapier
parent 7f743178db
commit 85fe75d1cb
12 changed files with 118 additions and 40 deletions

View file

@ -452,17 +452,18 @@ Server::~Server()
}
}
void Server::start(unsigned short port)
void Server::start(Address bind_addr)
{
DSTACK(__FUNCTION_NAME);
infostream<<"Starting server on port "<<port<<"..."<<std::endl;
infostream<<"Starting server on "
<< bind_addr.serializeString() <<"..."<<std::endl;
// Stop thread if already running
m_thread->Stop();
// Initialize connection
m_con.SetTimeoutMs(30);
m_con.Serve(port);
m_con.Serve(bind_addr);
// Start thread
m_thread->Start();
@ -477,7 +478,8 @@ void Server::start(unsigned short port)
<<" \\/ \\/ \\/ \\/ \\/ "<<std::endl;
actionstream<<"World at ["<<m_path_world<<"]"<<std::endl;
actionstream<<"Server for gameid=\""<<m_gamespec.id
<<"\" listening on port "<<port<<"."<<std::endl;
<<"\" listening on "<<bind_addr.serializeString()<<":"
<<bind_addr.getPort() << "."<<std::endl;
}
void Server::stop()