Home > Back-end >  The problem of TIdUDPClient
The problem of TIdUDPClient

Time:09-28

Everybody is good, I now want to write a communication software, using Delphi xe7, chose IdUDPServer IdUDPClient with these two controls, now the client with a button to send and receive information:
 procedure. Tfm_main Button1Click (Sender: TObject); 
Var
MessageID: Integer;
ThisMessage: String;
ReceivedString: String;
The begin
UDPClient. Send (' ABC ');//use this sentence to send,
ReceivedString:=UDPClient ReceiveString ();//use this sentence to receive
The end;


The communication is no problem, but I think the functions as follows:

Has A and B two client, there is A S the service side, in order to realize A through S sending message to B, now the problem is, TIdUDPClient did this control can receive instant server, the method of sending information now receiving, by A Timer control code is as follows:
 procedure Tfm_main. Timer1Timer (Sender: TObject); 
Var
ReceivedString: string;
The begin
If not vconetion then
exit;
ReceivedString:=UDPClient ReceiveString ();
If ReceivedString & lt;> "' then
The begin
UDPMemo. Lines. The Add (+ ReceivedString Received:);
The end;

The end;


But such a good card, also not reality, I want to ask, how to solve this problem, when the server sends the information to respond?
thank you

CodePudding user response:

IdUDPserver read attributes, data receiving, not receiving

CodePudding user response:

I know, but my client is using this IdUDPClient control,

CodePudding user response:

reference 1st floor houjiuhong response:
idUDPserver have read attributes, data receiving, without receiving
I know, but my client is using this IdUDPClient control

CodePudding user response:

reference 1st floor houjiuhong response:
idUDPserver have read attributes, data receiving, without receiving

CodePudding user response:

 
IdUDPClient1. ReceiveTimeout:=50;//set the waiting time is very short,
0.05 secondsS:=IdUDPClient1 ReceiveString ();//receiving, timeout, next time again to receive the

The above can simply solve the problem of card slightly
If the effect is good, or should be put to receive in the separate thread to complete, received content post-processing, notify the main thread after showing what of,
  • Related