Help with UDP

Hi,



I am trying to get my head around UDP. Everything works with TCP. When I switch some of my messages to UDP and connect with a single client everything works great. However, when I connect with a second client (on the same machine) I receive the same message multiple times.



It is only sent once but I get the message received with the message a number of times. I am sending using the broadcast message and listening using a MessageListener. The server only receives the message once, but the clients get it 10 or 11 times.



I am a bit baffled by this, any help would be appreciated.



Matt

Hm, SM has some bugs that are bing fixed right now… But I didnt experience this… The main difference between UDP and TCP is that when you use UDP the messages might arrive in a dfferent order than they were sent. Maybe that produces the results in combination with your code?

That’s what I thought at first as well. But I put logging at the sending point and receiving point and I send a message once but receive it multiple times. It only happens with more than 1 client connected and only on the calls from the server to the clients (not the other way around). I was wondering if it was to do with connecting from the same IP address multiple times?



I can check out the code and debug if it is not known behaviour.



Matt

As said, its being worked on right now by a secret contributor :wink:

Cool. I just tried to recreate this with a simple client server set-up and could not which means it may be my code, or another action is triggering it. I will keep investigating from my side.



Matt

Beware of UDP… it is currently not at all thread safe in some bad ways. In other words, if you were to try to send a UDP message from the render thread (say on update) as well as at the same time sending one as a response to a message from the server… then you potentially corrupt both messages. At least that’s my reading of the code.



…as normen hinted. Hopefully this all gets fixed soon.