Problem with ACK response
Posted: Mon Apr 09, 2012 6:51 pm
When I receive the message ORM, return an ACK (TCP Indy). Sending a batch of messages (ten) done correctly the first 5 and the sixth broke my connection (Connection Closed Gracefully).
Can it be to have trial components installed yet?
I post the code is the event of idTCPServer OnExecute.
A greeting
Can it be to have trial components installed yet?
I post the code is the event of idTCPServer OnExecute.
Code: Select all
procedure TForm4.IdTCPServer1Execute(AContext: TIdContext);
var
Bloques: integer;
i: integer;
TamanoBloque: integer;
trozoTexto: ansistring;
texto: ansistring;
ack: TdiACK_25;
begin
TamanoBloque := 1024;
// Receive
Bloques := StrToInt(AContext.Connection.IOHandler.ReadLn);
texto := '';
for i := 0 to Bloques do
texto := texto + AContext.Connection.IOHandler.ReadLn;
texto := MimeDecodeString(texto);
//Result := texto;
memo1.lines.add(texto);
// Send
ack := TdiACK_25.Create;
try
////////////////////////////
texto := ack.AsXML; // I GET ERROR HERE (with "ack.AsString" Too)
////////////////////////////
texto := MimeEncodeStringNoCRLF(texto);
Bloques := Length(texto) div TamanoBloque;
AContext.Connection.IOHandler.writeln(IntToStr(Bloques));
for i := 0 to Bloques do
begin
trozoTexto := ansistrings.AnsiMidStr(texto, (TamanoBloque * i) + 1, TamanoBloque);
AContext.Connection.IOHandler.writeln(trozoTexto);
end;
finally
freeandnil(ack);
end;
end;