Registriert seit: 4. Feb 2006
Ort: Hamburg
1.296 Beiträge
Turbo C++
|
AW: Indy10: TIdIOHandler.ReadLn hängt Programm auf
3. Aug 2010, 17:41
Hallo Martin,
schau Dir mal bitte das Beispiel von Remy an:
http://stackoverflow.com/questions/5...ytes-in-the-in
Daraus zitiert:
Delphi-Quellcode:
procedure TFormMain.IdTCPServerExecute(AContext: TIdContext);
var
RxBuf: TIdBytes;
begin
RxBuf := nil;
with AContext.Connection.IOHandler do
begin
CheckForDataOnSource(10);
if not InputBufferIsEmpty then
begin
InputBuffer.ExtractToBytes(RxBuf);
// process RxBuf as needed...
end;
end;
end;
Alternativ:
procedure TFormMain.IdTCPServerExecute(AContext: TIdContext);
var
RxBufStr: String; // not UTF8String
begin
with AContext.Connection.IOHandler do
begin
CheckForDataOnSource(10);
if not InputBufferIsEmpty then
begin
RxBufStr := InputBuffer.Extract(-1, enUtf8);
// Alternatively to above, you can set the
// InputBuffer.Encoding property to enUtf8
// beforehand, and then call TIdBuffer.Extract()
// without any parameters.
//
// Or, set the IOHandler.DefStringEncoding
// property to enUtf8 beforehand, and then
// call TIdIOHandler.InputBufferAsString()
// process RxBufStr as needed...
end;
end;
end;
Gruß,
Assertor
Frederik
|
|
Zitat
|