Ich versuche es nochmal zu erklären.
Threadübersicht:
UDPServer Anzahl 1 = Thread Nummer 1
UDPClient Anzahl 1..35 = Thread Nummer 2..36
Verarbeitungsthread Anzahl 1..35 = Thread Nummer 37..71
weitere Threads, die für andere Funktionen zuständig sind, allerdings den Verarbeitungsthreads 37..71 auch Nachrichten schicken können.
UDPServer gibt die empfangenen Daten an den UDPClient weiter, via PostThreadMessage
UDPClient gibt Daten nach Prüfung und Validierung und anderen Dingen, an den Verarbeitungsthread weiter, via PostThreadMessage
Verabreitungsthread sieht ungefähr so aus:
Delphi-Quellcode:
while not Terminated do
begin
Return := MsgWaitForMultipleObjects (Handles, HandleBuffer, False, 251, QS_ALLINPUT);
//case Return do
//WAIT_OBJECT_0
//WAIT_OBJECT_0+Handles
// : begin
// while PeekMessage(MessageData, 0, 0, 0, PM_REMOVE) do
// begin
// Mach irgendwas mit der Nachricht...
// end;
// end;
//WAIT_TIMEOUT
//end;
//zyklischer Aufruf
var sw := TStopwatch.StartNew;
var TC : DWORD;
var TC2 : DWORD;
TC := GetTickCount;
//Synchronize(MeineFunktion);
//Queue(Nil, MeineFunktion);
//ForceQueue(Nil, MeineFunktion);
t1 := sw.ElapsedMilliseconds;
//Protokollierung von t1 ...
TC2 := GetTickCount - TC;
//Protokollierung von TC2 ...
end ;
Wie gesagt, nur ein grober Auszug...
Thank you and well i think we are getting somewhere,
This raise few questions why to mention UDPClient here ? what are their proposes on server side ? if you are responding then use SendTo from the server Binding/Handler to get better idea refer to this example
https://github.com/tinydew4/indy-pro...ServerMain.pas
May be your server doesn't use UDPCLient and this miss understanding on me (translation or something) we get to different problematic approach THE loop
here how to do loop and
handle thread messages
https://stackoverflow.com/questions/...ultipleobjects
https://devblogs.microsoft.com/oldne...17-00/?p=36423
Read the question and answers on SO also all the comments there, specially this one
Zitat:
DANGER This is the code that has the bug Raymond wrote about. You need to loop on the peekmessage.