Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
UdpSocket.hpp typo in comment for void unbind() #1121
Function void unbind();
Typo in word "available" contradicts with function's designation:
@eXpl0it3r: Yep, it indeed needs clarification. But maybe there's more that need to be fixed. I quickly read through the doc and examples. Despite being clear that
Yes, the port is available for a different usage. The socket is simply closed and next time it is used it will be re-opened -- well, that's what the implementation tells me.
To make it even less ambiguous, I would prefer something like:
/// The port that the socket was previously bound to is immediately /// made available to the operating system after this function is called. /// This means that a subsequent call to bind() will be able to re-bind /// the port if no other process has done so in the mean time.
The reason why the UDP client example works is because we sent something prior to receiving. It is perfectly normal to fire single-shot datagrams at whatever destination without caring about a response, thus sending does not require binding to a known port if it is not necessary. In this case, the operating system temporarily binds the socket to an ephemeral port (those really huge ones) since it assumes the socket/connection is going to be short-lived. If the server responds fast enough using the sender address/port they will manage to get their reply datagram routed to the right process using the ephemeral port. This is what happens in the example, and sure... it might be counter-intuitive at first sight to someone learning networking while using SFML, but for someone who has worked with UDP before it is completely normal to write clients like that.