Autor Beitrag
endeffects
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41



BeitragVerfasst: Mo 05.07.04 17:14 
hallo,

also ich hab eine bestehende server verbindung
und sende einen request an diesen server,
dessen antwort möchte ich über readbuffer(); in
ein memo packen, allerdings endet das ganze
in einem exception error (EAccessViolation)

mein code ist folgender:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TForm.Button1Click(Sender: TObject);
var cb: string;
begin
  with IdTCPClient do
    begin
      try
        Write('request');
        if IOHandler.Readable(1000) then
        begin
          ReadBuffer(CB, SizeOf(CB));
           if SizeOf(CB) > 0 then
           begin
            Memo.Lines.Add(CB);
            end;
           end;
      except
        on E : Exception do
          ShowMessage(E.Message);
      end;
    end;
end;


Jemand vielleicht eine Idee woran das liegt?
(ReadLn möchte ich übrigens nicht benutzen)
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mo 05.07.04 19:04 
mach es bei nem string nicht mit readbuffer osndern mit readln

_________________
In the beginning was the word.
And the word was content-type: text/plain.
endeffects Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41



BeitragVerfasst: Mo 05.07.04 20:17 
wie gesagt, ich möchte auf den einsatz von readln verzichten
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 06.07.04 12:15 
warchienlich, weil die größe einens strings nicht eindeutig mit sizeof ermittelbar ist.
dann gibt die funktion einen schmarrn zurück und dein code erzeugt eine zugriffsverletzung weil er da lesen will wo er nicht darf oder nicht kann.

_________________
In the beginning was the word.
And the word was content-type: text/plain.
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Di 06.07.04 12:34 
Müsste das nicht mit
ausblenden Delphi-Quelltext
1:
2:
SetLength(CB, 1024);
ReadBuffer(CB[1], Length(CB));
funktionieren?


Moderiert von user profile icontommie-lie: Delphi-Tags korrigiert... du müsstest langsam wirklich wissen, wie die gehen... :mahn:

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert


Zuletzt bearbeitet von tommie-lie am Di 06.07.04 15:25, insgesamt 1-mal bearbeitet
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 06.07.04 14:56 
ja du musst ihm halt ne definerte länge sagen !

_________________
In the beginning was the word.
And the word was content-type: text/plain.