TimonPost / laminar

A simple semi-reliable UDP protocol for multiplayer games
821 stars 66 forks source link

Use `::bind_any()` instead of `::bind(addr)` in example for client to avoid confusion #306

Open DragonAxe opened 1 year ago

DragonAxe commented 1 year ago

In the server_client.rs example, there are two address:port constants, one for the server and one for the client: https://github.com/TimonPost/laminar/blob/db4873cbad61aaf12688336174ac82f40992cd12/examples/server_client.rs#L10 https://github.com/TimonPost/laminar/blob/db4873cbad61aaf12688336174ac82f40992cd12/examples/server_client.rs#L51 These addresses are 40 lines apart, so I missed that the port numbers are different. Port 12351 for the server and 12352 for client. When adapting the example to my project, I accidentally merged the two addresses to one variable.

I feel it would be better to use ::bind_any() instead of ::bind(addr) for the client to help prevent the confusion I encountered. https://github.com/TimonPost/laminar/blob/db4873cbad61aaf12688336174ac82f40992cd12/examples/server_client.rs#L52 It seems common for client programs to pick any open port to bind to which is why ::bind_any() seems like a good option.

merlindru commented 1 year ago

I learned about bind_any through your post. Thank you!