lsalzman / enet

ENet reliable UDP networking library
MIT License
2.71k stars 669 forks source link

Connecting multiple peers #169

Closed GitOlli closed 2 years ago

GitOlli commented 3 years ago

Hello! I'm making a game with ENet and sfml. I have been testing around with ENet and i was wondering what is the correct way to connect multiple peers from a single ENet client? I have tried many different configurations but the peers don't seem to connect. I didn't find anything related to this.

bjorn commented 3 years ago
GitOlli commented 3 years ago

Do i need to have different ENetAddresses for each peer?

bjorn commented 3 years ago

Do i need to have different ENetAddresses for each peer?

No, that struct is only used by enet_host_connect during its call, and can be reused for another call afterwards. Normally you'd allocate it on the stack.

Though, you would change its host and/or port members for each call, right? Otherwise you're connecting to the same foreign host each time.