Working Example of UDP Client/Server

Someone asked for my help on getting UDP working with Solar 2D a while back and then later I stumbled upon some working code in my junk pile:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2020/07/udp_client_server.zip

Hopefully it gives someone a starting point. It may require some real digging to get it in shape for your game/app, but hey. It seems to work!

7 Likes

Very interesting.

I suggest also to take a look at Photon network: is free just for a little number of client, but not so expensive.

Renato

@renato.rolando - Thanks. I’m definitely interested in hearing what MP solutions are working for folks currently.

I’m sure others are too, so if anyone else reads this and is using a current service for MP related game dev with CoronaSDK/Solar2D please post back here with info.

From @renato.rolando: Photon

For knowledge I used it for a basic game: pong.

I put two players on the net with Photon.

This seems trivial; in reality the exchange of data is not fast enough to guarantee the transmission of the position of the ball in real time. We need to study some tricks.

Photon works, quite good. I think also for Apple, but I develop on Android.

The major flaw about me on Phong is that if a Client does not transmit its “ack” within about 2 or 3 seconds it is automatically disconnected.
But also the way to ‘go out’ gracefully is precisely that.

Often in my tests I happened to get out of the connection and re-enter too quickly with obvious connection problems. Even in the game, for example you have finished a game and you want to reconnect. Also all the other Client receives the ‘log out’ of Client 2 or 3 secs after the Client is logged out.

Personally I miss a synchronous service connection (for example deciding who is holding the points, when a point has been scored, which side of the field each one must occupy and so on), a kind of blackboard available to all players, but perhaps it’s me who didn’t find it.

I posted on the forum how to decide what Client will be the Master on the game.

The version for Solar2D is older than the new shiny release for Unit with many more features, some interesting.

That’s all folks!

Renato