lidgren-network-gen3 icon indicating copy to clipboard operation
lidgren-network-gen3 copied to clipboard

[QUESTION] Thread safety

Open iProgramMC opened this issue 4 years ago • 5 comments

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?

iProgramMC avatar Jun 22 '20 14:06 iProgramMC

It is all ready thread safe 👍

guerrillacontra avatar Jul 31 '20 19:07 guerrillacontra

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

iProgramMC avatar Jul 31 '20 19:07 iProgramMC

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

guerrillacontra avatar Jul 31 '20 20:07 guerrillacontra

ah, will do later

iProgramMC avatar Jul 31 '20 20:07 iProgramMC

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?).

PJB3005 avatar Aug 02 '20 15:08 PJB3005