Bonjour,
j'ai un prog qui fonctionnait en indy 9 que je migre en Indy10
ce prog IdTcpClient
1) envoi un block de byte
2) doit attendre la réponse (mini time out)
3) receptionne les datas à mettre dans des Bytes
la connexion c'est OK
l'envoi ça parait Ok
mais la recption c'est toujours "connection closes gracefully"
si quelqu'un à un exemple ou une solution
Merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 function TVmModBusTcp.ExeTcp_SendAndReceive(IdClient:TIdTCPClient;SendBuffer,ReceiveBuffer: TMBDataBuffer): boolean; var VBuffer: TIdBytes; s:string; dtTimeOut:TDateTime; begin Result := false; with IdClient do begin //<< version indy 10 // (STEP 1) : connexion try //param Host,etc is before load if Not Connected then connect; // pas de PB except on E:Exception do begin s:=E.Message; //<<Error_1 :connexion exit; end; end; try // (STEP 2) : send Trame of byte IOHandler.Write(RawToBytes(SendBuffer, 12)); Sleep(5); // (STEP 3) : Wait a few milisecond the response (mini time out) dtTimeOut := IncMilliSecond(now,200); while (IOHandler.InputBuffer.Size = 0) do begin if IOHandler.Readable(0) then // ReadFromStack //indy 9 but not indy 10 ?? else Sleep(5); //test déconnexion if (Now > dtTimeOut) And (Not Connected) then begin Exit; end; end; //while // (STEP 4) : Receive Data and transfert in Buffer Btyte move(IOHandler.InputBuffer,ReceiveBuffer,IOHandler.InputBuffer.Size); except on E:EIdConnClosedGracefully do S:=E.message; //Error_2 "connection closes gracefully" ???? end; end; //with IdClient end;
Partager