برنامه ای نوشتم با دلفی 7 که تو اون سرورحداکثر 4 کاربر فعال را با tcpclient/server میگیره تا زمانی که کاربر پنجم نیامده سرور برای چک کردن وصل بودن این 4 تا اقدام نمیکند وقتی پنجمی اومد در رویداد onconnect Tcpserver سمت سرور این کار را انجام میدهد
//server side
procedure TForm1.IdTCPServer1Connect(AThread: TIdPeerThread);
begin
//when fifth user want to connect to tcpserver
//server first ensure at list one of the 4 connected user in grid has disconnected
//by send udp broadcast to 4 user
//but in this timeout None of these users do not respond , Although still connected
IdUDPClient1.Broadcast('IP', 1718);
For i:=1 To 4 Do
begin
IPList.Add(IdUDPClient1.ReceiveString(200););
end;
end;
//client side
procedure TForm1.IdUDPServer1UDPRead(AThread: TIdPeerThread);
begin
//
ip:=GetipAddress();
IdUDPServer1.sendto(ip);
end;
منتهی درون این بازه timeout هیچ کدام جواب نمیدهند ولی وقتی Timeout را زیاد میکنم تا 4000 جواب میدهد چرا این جوریه؟چکار اشتباهی انجام دادم
درون رویداد onconnect مربوط به tcpserver میام چک میکنم آیا 4 کاربر همچنان متصل هستند یا نه . این کار را با udp broadcast به تمام این کاربران انجام میدهم