C# Socket problems

Started by
2 comments, last by Djvilppu 12 years, 8 months ago
[font="Arial"]Hello,[/font]

[font="Arial"]I am making some little scale multiplayer game with C# (.NET 4..0) and sockets... And now I need some socket expert help.[/font]

[font="Arial"]All have gone before well. M[/font][font="Arial"]y "good" clients takes [/font][font="Arial"]bandwich (both uplload and download) [/font][font="Arial"]about 2kbs / sec.[/font]

[font="Arial"]Now I got few tester with bad connection. [/font]
[font="Arial"]Bad connection causes server uppload bandwich jump up to 1000kbs per/sec a[/font][font="Arial"]nd it totally incapacicate server.[/font]

[font="Arial"]Some point of interests:[/font]
[font="Arial"]* Using TCP/IP[/font]

[font="Arial"]* I launch one thread per client (Will be good on my game, I need about 10 connections max)[/font]

[font="Arial"]* When is set TcpClient property NoDelay = true... This will make things even worse! (And it is strange)[/font]
[font="Arial"]- [/font][font="Arial"]NoDelay = false. (Bad connections cause about 400kbs/sec spike to client!)[/font]
[font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"]- [/font][font="Arial"]NoDelay = true. (Bad connections cause about 1000kbs/sec spike to client!)[/font][/font][/font]
[font="Arial"][font="arial, verdana, tahoma, sans-serif"] [/font][/font]
[font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"]* I give threads sleep when they got time with method "System.Threading.Thread.Sleep(100);" (Is this right way to do it?)[/font][/font][/font]
[font="Arial"][font="arial, verdana, tahoma, sans-serif"] [/font][/font]
[font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"]* Using binaryformatter and networkstream.[/font][/font][/font]
[font="Arial"][font="arial, verdana, tahoma, sans-serif"] [/font][/font]
[font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"]* Using .NET 4.0.[/font][/font][/font]
[font="Arial"][font="arial, verdana, tahoma, sans-serif"] [/font][/font]
[font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"]I put with my client codes in zip:[/font][/font][/font]
[font="Arial"]Client.cs[/font]
[font="Arial"]DatanHandler.cs[/font]

[font="Arial"]and serverside:[/font]
[font="Arial"]Server.cs[/font]
[font="Arial"]ClientHandler.cs[/font]

[font="arial"]Attention!:[/font]
[font="arial"]I have simplified code for GameDev-post. But all important should be there.[/font]

[font="arial"]So my question is:[/font]
[font="arial"]What am I doing wrong?[/font]
[font="arial"]What is right way to fix it?[/font]
[font="arial"]Do you see some other major problems on my code?
[/font]
[font="arial"]Ps. I will send more info if needed.[/font]
Advertisement

[font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"]I put with my client codes in zip:[/font][/font][/font]


It's unlikely anybody will download your code and unzip it just to read it and maybe find a problem.

What have you tried on your own? If you capture the traffic with WireShark, what data is being sent? When you see the large bandwidth usage, which kinds of data packets are you seeing in the client and server side? Are you logging a message for each packet sent and received? Have you stopped the program while it's being "bad" and single-stepped through it in the debugger to see what it's doing?
enum Bool { True, False, FileNotFound };

[quote name='DJV' timestamp='1313731126' post='4851057']
[font="Arial"][font="arial, verdana, tahoma, sans-serif"][font="Arial"]I put with my client codes in zip:[/font][/font][/font]


It's unlikely anybody will download your code and unzip it just to read it and maybe find a problem.

What have you tried on your own? If you capture the traffic with WireShark, what data is being sent? When you see the large bandwidth usage, which kinds of data packets are you seeing in the client and server side? Are you logging a message for each packet sent and received? Have you stopped the program while it's being "bad" and single-stepped through it in the debugger to see what it's doing?
[/quote]

* No I have not captured traffic. (This first time I use WireShard... and it seems to be tool what I just need).

* Yes I have tried debug when things goes bad but got nothing from it yet.

Are you logging a message for each packet sent and received?[/quote]
I have not this kind technology on my game.. But I add it now.

I post more info if needed.. But I think I am going well with WireSharks.
Thanks.
Found problems with [color="#1C2837"]WireShark.

[color="#1C2837"]My "Command queue" got bug. Bug fixed.
[color="#1C2837"]Now all clients takes ~ 5 Kbs/Sec.
[color="#1C2837"]
[color="#1C2837"]This thread can be closed.
[color="#1C2837"] Thanks.


This topic is closed to new replies.

Advertisement