Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange characters in string with c# sockets
    text
    copied!<p>We are working on an RTS game using XNA, and I've been tasked with the networking (well, we kind of finished the game, and I recently picked it back up). To cut to the chase, I have had a ton of issues with sockets, missing packets mostly for a lot of different reasons, but I think I've solved most of them. (We're using TCP even ..)</p> <p>To try to solve issues, I've created a network tester, which will send packets to the server, which will send them back, after which I can see if there were dropped packets etc.</p> <p>One of my tests is a 'deform' test. Basically I grab the random function, generate a number, convert it to an MD5 String, and send it to the server. When I receive it back, I compare it to the strings already sent, and see if there was any corruption (comparison <em>should</em> be 100%, as in, all sent strings were found in the received list).</p> <p>Now, here's a snapshot of the results:</p> <p>Sent: </p> <pre><code> [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 </code></pre> <p>Received:</p> <pre><code> [0] "&amp;\0\069-AB-DA-CC-1A-66-6A-27-C5-B4-FF-B7-2D-9F-75-06" string [1] "&amp;\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 </code></pre> <p>I'm getting roughly 50% packets correct. I could post the socket code and such, but I dare say it's rather complex. Still, if it's needed, I'll post it. Is there some socket-related thing I'm missing? I am hoping for a quick fix .. but I doubt there will be any seeing previous problems we had.</p> <p>Thank you in advance for any suggestions.</p> <p>Edit: View the github repository here: <a href="https://github.com/Wotuu/RTS_XNA_v2/tree/master/SocketLibrary" rel="nofollow">https://github.com/Wotuu/RTS_XNA_v2/tree/master/SocketLibrary</a></p> <p>By request, some code snapshots: MD5 creation: <a href="https://github.com/Wotuu/RTS_XNA_v2/blob/master/PathfindingTest/PathfindingTest/UI/Menus/Multiplayer/TestConnectionMenu.cs" rel="nofollow">https://github.com/Wotuu/RTS_XNA_v2/blob/master/PathfindingTest/PathfindingTest/UI/Menus/Multiplayer/TestConnectionMenu.cs</a> :222</p> <p>String->byte: <a href="https://github.com/Wotuu/RTS_XNA_v2/blob/master/SocketLibrary/Packets/Packet.cs" rel="nofollow">https://github.com/Wotuu/RTS_XNA_v2/blob/master/SocketLibrary/Packets/Packet.cs</a> :113</p> <p>byte->String: <a href="https://github.com/Wotuu/RTS_XNA_v2/blob/master/SocketLibrary/Packets/PacketUtil.cs" rel="nofollow">https://github.com/Wotuu/RTS_XNA_v2/blob/master/SocketLibrary/Packets/PacketUtil.cs</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload