Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Matrix1 Utils TCP random crashing when receiving string

Author
Message
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 16th Mar 2016 19:57 Edited at: 16th Mar 2016 19:59
For some reason, even the TCP connection of Matrix1 Utils have problems, in this case, random crashes when receiving data.
This is an example of the code I use to forward and request data for my game to the server I have:



I have set some crash logging functions between any action of this code (connect, send, receive etc) and when the game crashes it Always crashes when the command "RECV SOCKET STRING$" is called.
I use to set the TIMEOUTCONNECTION to 50 or 100 ms (if you don't use a timeout a request could take too much time and the game stutters too much, at least with a timeout is limited), but I will probably implement a dynamic value (if is too low obviously miss the communication, usually below 25 ms, if too high stutters so much when trying to connect, so it's better to miss a communication if it takes for example 300-500 ms, as at this time there should be other communications to be done and the old ones are useless).
I call this function every 200 ms, so the game updates the server 5 times per second.

Sometimes the game crashes after a few seconds, but most of the times after minutes, and in rare cases after 10 minutes.

Another problem I wish to fix is how to have the communication with the server without let the game wait for it, otherwise it stutters a bit (it's not smooth), and obviously lower the fps because every frame lose time for the connection.
Ortu
DBPro Master
17
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 17th Mar 2016 19:42
You shouldn't need to constantly create and close the socket, just create it once and leave it open for further use
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 17th Mar 2016 20:25 Edited at: 17th Mar 2016 20:27
Do you have an example of the code? Because I have already tried this and I was getting errors.
By the way I have been able "at least" to fix the crash thing, working on the php code server side:
Basicly there I was opening both the main socket and the receive socket in the while loop, while now I open the main socket out of the main loop and only keep opening the receive socket.
This improved the performance but what fixed the crash thing is a check I have made in every socket operation, so that if one operation fails the following ones on the same cycle are not called.
For example, I have noticed "making my own error log system" that once in a while the server fails to receive (probably because of the timeout I have set but not sure 100%), when that happened with the old code the write socket was called even without receiving anything so probably that is what causing the error, I think.
Now my only problem is improve the performance so that I don't lose too much time everytime the connection is called, what you are saying about opening the main socket once and not every call will probably be the solution, but from my previous tests it wasn't working somehow
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 17th Mar 2016 20:41
Here's the tests:

1- Opening the socket before the loop and removing the delete socket command = (Unable to transmit, cannot send after socket shutdown)
2- Like 1 but also removing SHUTDOWN SOCKET SEND Connection = (Crash)
3- Like 1 but also removing SHUTDOWN SOCKET SEND Connection and SHUTDOWN SOCKET RECV Connection= (Unable to receive, end of socket stream)
Derek Darkly
13
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 12th May 2016 13:17 Edited at: 12th May 2016 13:24
Hello Cescano,
Just curious if you ever had any luck getting your connections working again....?

Also, are you connecting to players in a local network only, or are you able to use Matrix1Utils to connect to players anywhere? This is what I'm working on currently - my local connections work, I'm just trying to figure out what IP addresses to use for outside connections.

Would you have a sample of public IP connection?
The socket commands return an IP I don't recognize, and my public IP doesn't seem to work.
I wish the tutorials were more in-depth.
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 12th May 2016 16:21
Hi, I actually communicate with a main server (a VPS), and not with other players directly.
I have moved the game data transfer to the UDP protocol which is faster, sadly DBPro doesn't support multithreading so the time used for the connection slow down the game fps.
I only use TCP for things like logging a player for example.
The game I have made with this is finished and free to play, downloadable from www.galleonmate.com, sadly finding players to fill a 32 players server is very tough.
I cap the fps of the game to 50 (like I did in my previous games too, as floating fps make the game not smooth), but probably it can't push more than that with any hardware due to the single core limitation I mentioned before.
www.89amstudio.com
Derek Darkly
13
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 13th May 2016 04:45

Hey, I just watched your trailer... looks very nice!

Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 13th May 2016 05:03 Edited at: 13th May 2016 05:04
Thank you very much!
Sadly as I said is very very hard to find players for games like this (I mean 32 players matches), even advertising it everywhere, also paying Google ads: when 1 player discover the game, he enters, see nobody, quit, another player enters, see nobody, quit, and so on.
I am trying to work on the SEO of the game website to see if I can get some more people from the Google search as well, but I am afraid that I will never see a decent match going on.
I don't know how other games get so many players, probably I don't have enough advertising power.
www.89amstudio.com
Derek Darkly
13
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 13th May 2016 13:00 Edited at: 13th May 2016 13:03
Quote: "I don't know how other games get so many players, probably I don't have enough advertising power."


I know what you mean...all I ever hear about is Steam anymore. Have you submitted your game there for people to vote on?

Also, I don't know the rules of your game, but have you considered letting less players use more stations on the ship to cover the missing ones? That way you could have as few as 2 players in a match, each controlling their whole ship...then again if this is a real-time game and not turn based I suppose it would be hard to do everything fast enough, but at least the challenge would still be the same for each player.
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 13th May 2016 15:41 Edited at: 13th May 2016 15:45
I have already other 2 games on steam, but this one is free to play and I have already setup everything with paypal payments, both boosters or server rentals (you can rent your own server and load your own map made with the map editor included in the game).
Moving this to steam they will require everything to be converted with the steam wallet, and they will take a huge cut on the payments, aproximately the half considering steam cut + taxes, while it could be ok for boosters payments will be a tough hit for the servers rental.

About the game, yes a single player could walk on the galleon and take each spot he wants, one of the 4 cannons spots or driving the galleon, so even with only 2 players on the server they could still play 1 vs 1.
Then when someone else join they could choose if take a spot in an empty galleon or join another player in that galleon.
There are a total of 16 galleons so each galleon has maximum 2 players slots, but even if there is just 1 player on the galleon he can play.
www.89amstudio.com
Derek Darkly
13
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 13th May 2016 17:09
Quote: "but even if there is just 1 player on the galleon he can play"


Oh I see.... is there AI to help the player, or is there AI for the enemy, or no AI at all?
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 13th May 2016 17:29
There is no AI at all, the other galleons spawn when a player choose a slot for that galleon, if you are the only player on the server there are no galleons around the map except yours.
www.89amstudio.com
Ortu
DBPro Master
17
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 15th May 2016 20:27
One thing you might think about for better match numbers: don't allow 24/7 access (until you consistently have numbers to support it). Have scheduled match times that people can coordinate and plan around, this can help drive traffic to those time slots and bring larger groups together for them.
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 15th May 2016 20:37
They don't know each other, also are very few, almost nobody entering during a day.
Seems that the registration/try game rate is about 10-20/1, but people who entered the 1st time never entered again, unless 1 player that tried 3 times in a day and then stopped to try.
www.89amstudio.com

Login to post a reply

Server time is: 2025-05-12 18:10:23
Your offset time is: 2025-05-12 18:10:23