Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi strings to stream dann via indy 10 verschicken (https://www.delphipraxis.net/74839-strings-stream-dann-via-indy-10-verschicken.html)

gandime 9. Aug 2006 13:21


strings to stream dann via indy 10 verschicken
 
hi,
ich hab mir mal eine procedure gemacht womit ich strings in array umwandele und dann via indy tcp-stream verschicke blos da is iwie ein fehler blos wo?

client:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  fsIN:tMemoryStream ;
  a_s_in:array[0..1000] of string;
  sl_in:tstringlist;
  i:integer;
  s_ss:tstringstream;
begin
  sl_in:=tstringlist.create;
  sl_in.add('a');
  sl_in.add('b');
  for I := 0 to sl_in.count - 1 do
  begin
    a_s_in[i]:=sl_in[i];
  end;
  fsIN:=tMemoryStream.Create;
  try
    fsin.Read(a_s_in,sizeof(a_s_in));
    FreeAndNil(fsIN);
  except
    exit;
  end;
  IdTCPClient1.Connect;
  IdTCPClient1.IOHandler.Write(fsin);// hier is der fehler: Access violation at address 00461AD2 in module "Project1.exe" read od address 00000000
  IdTCPClient1.Disconnect;
end;
server:
Delphi-Quellcode:
procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var
  fsOUT:tMemoryStream ;
  a_s_out:array[0..1000] of string;
  sl_out:tstringlist;
  i:integer;
  con:boolean;
begin
  fsout:=tMemoryStream.Create;
  sl_out:=tstringlist.create;
  while (con=true) do
  begin
    acontext.Connection.IOHandler.ReadStream(fsOUT);
  end;
  fsout.Write(a_s_out,sizeof(a_s_out));
  i:=-1;
  try
    while (i<1000) do
    begin
      i:=i+1;
      if (a_s_out[i]<>'') then
      begin
        sl_out.Add(a_s_out[i]);
      end;
    end;
  except
    exit;
  end;
  listbox1.items:=sl_out;
end;

chaosben 9. Aug 2006 13:58

Re: strings to stream dann via indy 10 verschicken
 
Delphi-Quellcode:
  try
    fsin.Read(a_s_in,sizeof(a_s_in));
    FreeAndNil(fsIN); //blos da is iwie ein fehler :)
  except
    exit;
  end;
  IdTCPClient1.Connect;
  IdTCPClient1.IOHandler.Write(fsin);// hier is der fehler: Access violation at address 00461AD2 in module "Project1.exe" read od address 00000000
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:13 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz