qwer85 Posted September 19, 2007 Share Posted September 19, 2007 I have UDP server, which wait's for client to connect, when it happens the server processes the packet and writes processed data to file. But when i connect simultaneously 5 clients - server logs only 2-3 of them. Why this happens? Server: expandcollapse popupOpt("MustDeclareVars", 1) UDPStartup() Global $socket = UDPBind("192.168.1.1", 65532) If @error <> 0 Then Exit Global $users[10][3] For $i = 0 To UBound($users, 1) - 1 For $k = 0 To UBound($users, 2) - 1 $users[$i][$k] = 0 Next Next Global $data While 1 $data = UDPRecv($socket, 1024) If $data <> "" Then If StringLeft($data, 4) = "qwer" Then Local $n_data = StringTrimLeft($data, 4) Local $IDnPass = StringSplit($n_data, "|") For $i = 0 To UBound($users) - 1 Select Case $users[$i][0] = 0 $users[$i][0] = $IDnPass[1] $users[$i][1] = $IDnPass[2] $users[$i][2] = TimerInit() ExitLoop Case $users[$i][0] = $IDnPass[1] $users[$i][2] = TimerInit() ExitLoop EndSelect Next _WriteData() ; write data into file EndIf EndIf For $i = 0 To UBound($users) - 1 If $users[$i][0] <> 0 And TimerDiff($users[$i][2]) >= 10000 Then $users[$i][0] = 0 $users[$i][1] = 0 $users[$i][2] = 0 _WriteData() EndIf Next WEnd Func _WriteData() Local $file = FileOpen("test.txt", 2) For $i = 0 To UBound($users) - 1 If $users[$i][0] = 0 Then ContinueLoop FileWriteLine($file, $users[$i][0] & " | " & $users[$i][1] & " | " & TimerDiff($users[$i][2])) Next FileClose($file) EndFunc Func OnAutoItExit() UDPCloseSocket($socket) UDPShutdown() EndFuncoÝ÷ Ø)bz{ZºÚ"µÍÜ ][ÝÓ]ÝXÛUÉ][ÝËJBQÝ BÛØ[ ÌÍÜÛØÚÙ]HQÜ[ ][ÝÌNLMKI][ÝË MLÌBYÜ ÉÝÈ[^]ÛØ[ ÌÍÜHH[ÛJKNNNKJBÛØ[ ÌÍÜÜÝÙH[ÛJLLLLLLLKNNNNNNNKJBÚ[HBQÙ[ ÌÍÜÛØÚÙ] ][ÝÜ]Ù][ÝÈ [È ÌÍÜH [È ][Ýß ][ÝÈ [È ÌÍÜÜÝÙ BTÛY L BÑ[[ÈÛ]]Ò]^] BQÛÜÙTÛØÚÙ] ÌÍÜÛØÚÙ] BQÚ]ÝÛ B[[ Link to comment Share on other sites More sharing options...
qwer85 Posted September 19, 2007 Author Share Posted September 19, 2007 Maybe it's because I run all these clients on same computer, a port gets overloaded? Link to comment Share on other sites More sharing options...
Kip Posted September 19, 2007 Share Posted September 19, 2007 (edited) use TCPquote from Wikipedia: UDP does not guarantee reliability or ordering in the way that TCP does, Data may arrive out of order, appear duplicated, or go missing without notice. Edited September 19, 2007 by kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
weaponx Posted September 19, 2007 Share Posted September 19, 2007 Isn't it obvious? "T" comes before "U" in the alphabet, TCP should be your first choice! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now