Explicitly set htons to 0

Also fix a typo.
This commit is contained in:
Stanislas Michalak 2020-04-20 09:20:00 +02:00 committed by GitHub
parent 4efe081084
commit f0e73cf81b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,7 +57,7 @@ void CSocket::Init ( const quint16 iPortNumber )
if (iPortNumber == 0)
{
// If port number is 0, bind the client to a random available port.
UdpSocketInAddr.sin_port = htons ( iPortNumber );
UdpSocketInAddr.sin_port = htons ( 0 );
bSuccess = ( ::bind ( UdpSocket ,
(sockaddr*) &UdpSocketInAddr,
@ -88,7 +88,7 @@ void CSocket::Init ( const quint16 iPortNumber )
else
{
// for the server, only try the given port number and do not try out
// other port numbers to bind since it is imporatant that the server
// other port numbers to bind since it is important that the server
// gets the desired port number
UdpSocketInAddr.sin_port = htons ( iPortNumber );