Jump to content
Sign in to follow this  
Glyph

TCP problems, messes up packets

Recommended Posts

Glyph

I notice that if in my multi client server, the tcpsends if sent faster then 100ms are sent incorrectly...

This has some serious problems with the server and client, if i get about 100 people connect, and there is a 100ms sleep - 100*100 = 10000

which is a 10 second lag... that is ridiculous!

now at 50ms = 5 seconds, but still unacceptable. if i get 200 people its still at 10 seconds.

Is there a reason for this?

here's my code:

Func broadcast($type, $misc)
Local $i = 0
If $Funnel[0][0] <> 0 Then
    Do
    $i += 1
    If $Funnel[$i][1] = True Then
        TCPSend($Funnel[$i][0], $type & "|" & $misc)
        sleep(50);lag
    EndIf
    Until $i = $Funnel[0][0]
EndIf
EndFunc   ;==>broadcast

tolle indicium

Share this post


Link to post
Share on other sites
trancexx

I notice that if in my multi client server, the tcpsends if sent faster then 100ms are sent incorrectly...

This has some serious problems with the server and client, if i get about 100 people connect, and there is a 100ms sleep - 100*100 = 10000

which is a 10 second lag... that is ridiculous!

now at 50ms = 5 seconds, but still unacceptable. if i get 200 people its still at 10 seconds.

Is there a reason for this?

here's my code:

Func broadcast($type, $misc)
Local $i = 0
If $Funnel[0][0] <> 0 Then
    Do
    $i += 1
    If $Funnel[$i][1] = True Then
        TCPSend($Funnel[$i][0], $type & "|" & $misc)
        sleep(50);lag
    EndIf
    Until $i = $Funnel[0][0]
EndIf
EndFunc   ;==>broadcast
Incorrectly how?

Try this and see if there would be any writings to console:

Func broadcast($type, $misc)
Local $i = 0
If $Funnel[0][0] Then
    Do
    $i += 1
    If $Funnel[$i][1] Then
        If TCPSend($Funnel[$i][0], $type & "|" & $misc) <> StringLen($type & "|" & $misc) Then; BinaryLen() depending on type of data
            ConsoleWrite("!: " & $i & @CRLF)
        EndIf   
    EndIf
    Until $i = $Funnel[0][0]
EndIf
EndFunc
Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
SmOke_N

Not that this has relevance to the question... But why use a Do/Until loop instead of a For/Next ?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Xand3r

I notice that if in my multi client server, the tcpsends if sent faster then 100ms are sent incorrectly...

This has some serious problems with the server and client, if i get about 100 people connect, and there is a 100ms sleep - 100*100 = 10000

which is a 10 second lag... that is ridiculous!

now at 50ms = 5 seconds, but still unacceptable. if i get 200 people its still at 10 seconds.

Is there a reason for this?

here's my code:

Func broadcast($type, $misc)
Local $i = 0
If $Funnel[0][0] <> 0 Then
    Do
    $i += 1
    If $Funnel[$i][1] = True Then
        TCPSend($Funnel[$i][0], $type & "|" & $misc)
        sleep(50);lag
    EndIf
    Until $i = $Funnel[0][0]
EndIf
EndFunc   ;==>broadcast
your func should work just fine the only problem you could have with the sleep is actually in your clients not in your server

when you send data very fast from the server it's very easy to overflow the read buffer of tcpread hence your loss of data...

try one of 2 things...

1: when you TcpRecv in your clients increase the second parameter ... try something like 1024*20=20k per recv

2:try to call tcprecv faster to prevent it from filling up at all^^

cheers

Edited by TheMadman

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites
Glyph

Weird, I tried a sleep(1), rather then 100 and, it works!

LOL. I overlooked that, but yeah... it works.

Also, was in a hurry on the loop, so did what came to mind first, i'll be optimizing the code once i worked out all the bugs, but im changing it to a for next loop, now.

Thank's for your help!

The problem was with the tcp sends sending too quickly, so one tcpsend would be fused with the other and sent once.

Edited by Glyph

tolle indicium

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×