lidgren / lidgren-network-gen3

Lidgren Network Library
https://groups.google.com/forum/#!forum/lidgren-network-gen3
MIT License
1.19k stars 331 forks source link

[QUESTION] Thread safety #141

Open iProgramMC opened 4 years ago

iProgramMC commented 4 years ago

I wonder, is Lidgren safe to use in multiple threads? I plan on having multiple hosts on my program, and I'm wondering if its possible with multiple threads. Also, is it possible that multiple threads can access the same host? Do I need to add something more to make it thread-safe, or is it already thread-safe?

guerrillacontra commented 4 years ago

It is all ready thread safe 👍

iProgramMC commented 4 years ago

Sounds good. Also, does lidgren support multiple hosts/servers per program?

guerrillacontra commented 4 years ago

I assume so as it's not a singleton, might have to experiment though

iProgramMC commented 4 years ago

ah, will do later

PJB3005 commented 3 years ago

Yes, multiple NetPeers works just fine in the same process (as long as you bind them to a different host:port pair, of course). I'm using it to implement dual stack IPv6 (because I didn't know what dual stack sockets were at the time, but I guess it provides compat with stuff like OpenBSD so yay?).