We are working on an RTS game using XNA, and I have been instructed to work on the network (well, we kind of finished the game, and recently I picked it up). To interrupt the chase, I had a lot of problems with sockets, missing packets mainly for various reasons, but I think I solved most of them. (We use TCP even ..)
To try to solve the problems, I created a network tester that will send packets to the server, which will send them back, after which I will see if the packets were dropped, etc.
One of my tests is the warp test. Basically, I take a random function, generate a number, convert it to an MD5 string and send it to the server. When I get it back, I compare it with the already sent lines and see if there was any damage (the comparison should be 100%, as in, all the sent lines were found in the received list).
Now take a snapshot of the results:
Sent:
[0] "69-AB-DA-CC-1A-66-6A-27-C5-B4-FF-B7-2D-9F-75-06" string [1] "1C-16-68-98-DF-6C-C9-16-54-5A-94-00-CA-57-77-CC" string [2] "B6-24-7E-79-0C-66-14-5B-C0-32-F5-17-06-5D-13-87" string [3] "1E-99-DE-1F-25-30-6E-DF-59-0D-05-2B-43-8F-07-16" string [4] "76-82-30-13-C2-B4-33-7D-32-E2-04-C7-13-3C-F3-AB" string [5] "23-BF-A2-F4-E4-77-78-6B-A5-2C-D2-6B-6F-B3-6F-44" string
Received:
[0] "&\0\069-AB-DA-CC-1A-66-6A-27-C5-B4-FF-B7-2D-9F-75-06" string [1] "&\0\01C-16-68-98-DF-6C-C9-16-54-5A-94-00-CA-57-77-CC" string [2] "B6-24-7E-79-0C-66-14-5B-C0-32-F5-17-06-5D-13-87" string [3] "1E-99-DE-1F-25-30-6E-DF-59-0D-05-2B-43-8F-07-16" string [4] "76-82-30-13-C2-B4-33-7D-32-E2-04-C7-13-3C-F3-AB" string [5] "23-BF-A2-F4-E4-77-78-6B-A5-2C-D2-6B-6F-B3-6F-44" string
I get approximately 50% of the packages correctly. I could publish the socket code, etc., but I dare say that it is quite complicated. However, if necessary, I will send it. Is there some kind of connected socket thing that I am missing? I hope for a quick fix. But I doubt that we will see the previous problems that we had.
Thanks in advance for any suggestions.
Edit: view github repository here: https://github.com/Wotuu/RTS_XNA_v2/tree/master/SocketLibrary
Upon request, some snapshots of the code: Creating MD5: https://github.com/Wotuu/RTS_XNA_v2/blob/master/PathfindingTest/PathfindingTest/UI/Menus/Multiplayer/TestConnectionMenu.cs : 222
String-> byte: https://github.com/Wotuu/RTS_XNA_v2/blob/master/SocketLibrary/Packets/Packet.cs : 113
byte-> String: https://github.com/Wotuu/RTS_XNA_v2/blob/master/SocketLibrary/Packets/PacketUtil.cs