Send-calls threadsave?

Hi all,

are the send-(Client) and the broadcast-calls(Server) threadsave? Can I call them from different threads at the same time or can this cause problems?
Especially on my server this is important, because some messages from clients have to be passed on to other clients. At the moment I just send them when my MessageListener<HostedConnection> fires, and I haven’t had problems yet, but I`d like to know if this is because it is safe or just because I had luck (or bad luck because I am unaware of a bug).

Thanks

Yes, networking is thread safe. Everything happens on different threads so it kind of has to be.

Ok, that makes sense. How is sending handled then? Are the messages enqueued in a message-queue? Or how else is ensured that Messages are sent one after another? Or doesn’t it matter if two Messages are sent at the same time?
I don’t think it will make a difference for the use of the API, I’m just curious :smiley:

@Toboi said: Ok, that makes sense. How is sending handled then? Are the messages enqueued in a message-queue? Or how else is ensured that Messages are sent one after another? Or doesn't it matter if two Messages are sent at the same time? I don't think it will make a difference for the use of the API, I'm just curious :D

Outbound messages are queued and sent by a separate thread but the queue is in order so the messages go out in order. For the TCP sockets that means they get to the other end in order. For UDP, no order can be guaranteed.

Thank you :slight_smile: