Don't hardcode broadcast port.

This commit is contained in:
Bartosz Taudul 2019-06-17 18:37:34 +02:00
parent 1b3b3a94a2
commit de058d2a0d
3 changed files with 4 additions and 4 deletions

View File

@ -1152,7 +1152,7 @@ void Profiler::Worker()
if( t - m_lastBroadcast > 5000000000 ) // 5s
{
m_lastBroadcast = t;
m_broadcast->Send( broadcastMsg, broadcastLen );
m_broadcast->Send( 8087, broadcastMsg, broadcastLen );
auto err = WSAGetLastError();
}
}

View File

@ -413,12 +413,12 @@ void UdpBroadcast::Close()
m_sock = -1;
}
int UdpBroadcast::Send( const void* data, int len )
int UdpBroadcast::Send( int port, const void* data, int len )
{
assert( m_sock != -1 );
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons( 8087 );
addr.sin_port = htons( port );
addr.sin_addr.s_addr = INADDR_BROADCAST;
return sendto( m_sock, (const char*)data, len, MSG_NOSIGNAL, (sockaddr*)&addr, sizeof( addr ) );
}

View File

@ -72,7 +72,7 @@ public:
bool Open( const char* addr, const char* port );
void Close();
int Send( const void* data, int len );
int Send( int port, const void* data, int len );
UdpBroadcast( const UdpBroadcast& ) = delete;
UdpBroadcast( UdpBroadcast&& ) = delete;