Set SO_REUSEADDR for listeners.

This commit is contained in:
Gunnar Beutner 2012-04-19 09:18:54 +02:00
parent 810a8215e6
commit 8621717f4c
2 changed files with 7 additions and 3 deletions

View File

@ -29,8 +29,12 @@ void TCPSocket::Bind(unsigned short port)
void TCPSocket::Bind(const char *hostname, unsigned short port)
{
sockaddr_in sin;
#ifndef _WIN32
const int optTrue = 1;
setsockopt(GetFD(), SOL_SOCKET, SO_REUSEADDR, (char *)&optTrue, sizeof(optTrue));
#endif /* _WIN32 */
sockaddr_in sin;
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = hostname ? inet_addr(hostname) : htonl(INADDR_ANY);

View File

@ -67,7 +67,7 @@ int IcingaApplication::Main(const vector<string>& args)
m_TestEndpoint->RegisterMethodSource("test");
m_TestTimer = make_shared<Timer>();
m_TestTimer->SetInterval(5);
m_TestTimer->SetInterval(1);
m_TestTimer->OnTimerExpired += bind_weak(&IcingaApplication::TestTimerHandler, shared_from_this());
m_TestTimer->Start();
@ -84,7 +84,7 @@ int IcingaApplication::TestTimerHandler(const TimerEventArgs& tea)
request.SetVersion("2.0");
request.SetMethod("test");
for (int i = 0; i < 1000; i++)
for (int i = 0; i < 10000; i++)
m_EndpointManager->SendMulticastRequest(m_TestEndpoint, request);
return 0;