crystyan
asked on
Upload with Indy
I need the code to upload with Indy. If possible I want to upload a TStringList without saving it in a temp file ?
Thanks
Thanks
ASKER
on a webserver.
The Indy 9 chat demo is very buggy
firstly, the client can lock up on the
Msg := IdTCPClient1.ReadLn('', 5);
line in the Timer1Timer() event
This can be resolved by putting a TIdAntiFreeze on the form, but you still get a memory leak
(just watch the task maanger while your client is connected)
To resolve this you need to disable the TTimer while doing the ReadLn, so your Timer1Timer routine ends up looking something like this :-
procedure TForm1.Timer1Timer(Sender: TObject);
var
Com,
Msg : String;
begin
if not IdTcpClient1.Connected then
exit;
Timer1.Enabled := False;
try
Msg := IdTCPClient1.ReadLn('', 5);
if Msg <> '' then
if Msg[1] <> '@' then
begin
{ Not a system command }
memLines.Lines.Add(Msg);
end
else
begin
{ System command }
Com := UpperCase(Trim(Copy(Msg, 2, Pos(':', Msg) -2)));
Msg := UpperCase(Trim(Copy(Msg, Pos(':', Msg) +1, Length(Msg))));
if Com = 'CLIENTS' then
lbClients.Items.CommaText := Msg;
end;
finally
Timer1.Enabled := True;
end;
end;
anyway, this may be the cause of your problems...
firstly, the client can lock up on the
Msg := IdTCPClient1.ReadLn('', 5);
line in the Timer1Timer() event
This can be resolved by putting a TIdAntiFreeze on the form, but you still get a memory leak
(just watch the task maanger while your client is connected)
To resolve this you need to disable the TTimer while doing the ReadLn, so your Timer1Timer routine ends up looking something like this :-
procedure TForm1.Timer1Timer(Sender:
var
Com,
Msg : String;
begin
if not IdTcpClient1.Connected then
exit;
Timer1.Enabled := False;
try
Msg := IdTCPClient1.ReadLn('', 5);
if Msg <> '' then
if Msg[1] <> '@' then
begin
{ Not a system command }
memLines.Lines.Add(Msg);
end
else
begin
{ System command }
Com := UpperCase(Trim(Copy(Msg, 2, Pos(':', Msg) -2)));
Msg := UpperCase(Trim(Copy(Msg, Pos(':', Msg) +1, Length(Msg))));
if Com = 'CLIENTS' then
lbClients.Items.CommaText := Msg;
end;
finally
Timer1.Enabled := True;
end;
end;
anyway, this may be the cause of your problems...
OOPS, sorry, ignore the above post, it was meant for another question ... my bad :-(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or to a Web server?
- tcp client side indy 9 -
TCPClient1.WriteInteger(my
for i := 0 to pred(mystringlist.count) do // loop through each line and send them 1 at a time
begin
TCPClient1.WriteLn(mystrin
end;
- tcp server side indy 9 -
var
i: integer;
newstringlist: tstringlist;
begin
newstringlist := tstringlist.create;
try
numlines := AThread.Connection.ReadInt
for i := 1 to numlines do
newstringlist.Add(AThread.
// do something with the stringlist now
finally
newstringlist.free;
end;
- tcp client side indy 10.0.52 -
TCPClient1.IOHandler.Write
for i := 0 to pred(mystringlist.count) do // loop through each line and send them 1 at a time
begin
TCPClient1.IOHandler.Write
end;
- tcp server side indy 10.0.52 -
var
i: integer;
newstringlist: tstringlist;
begin
newstringlist := tstringlist.create;
try
numlines := AContext.Connection.IOHand
for i := 1 to numlines do
newstringlist.Add(AContext
// do something with the stringlist now
finally
newstringlist.free;
end;