我的服务器表单有 stringgride 只接受 4 个 tcp 连接用户为此,我将 udpclient 放在我的服务器中,将 udpserver 放在客户端中
在服务器形式的 tcp-onconnect 事件中:
//Server Side has udp client
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 has udp server
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
begin
//
ip:=GetipAddress();
ABinding.SendTo(ABinding.PeerIP, ABinding.PeerPort, ip[1], Length(ip));
end;
我在客户端运行 ethereal 以检查网络并看到 udp 消息从服务器发送到客户端,但客户端没有响应。
请帮助我什么是我的代码问题