BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

dead lock

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
js
Guest





PostPosted: Wed Mar 16, 2005 4:26 am    Post subject: dead lock Reply with quote



hi, I have a kylix application use TCPClient to connect to a remote linux
server application in the Main thread:
if Not TCPClient.Connected then
begin
TCPClient.Host:= xxx;
TCPClient.Port:= xxx;
TCPClient.Connect(300);
end;
I found usually after 400 connections made, and the application would hang.
The call stack was show as it stops in the Connect statement (and some
waitfor statement in CPU debug window), the main thread is dead; only allow
me to run few instructions in CPU debug window.
I already specify 300 ms timeout value, why still cause dead lock? Any
thought about this? Please help...




Back to top
Guillem
Guest





PostPosted: Wed Mar 16, 2005 12:32 pm    Post subject: Re: dead lock Reply with quote



Hi,

Indy is a blocking-mode library, so i would suggest either to drop a
TidAntiFreeeze or to move the connecting to another thread. At least so it
will not freeze your program.

Btw, how are you disconnecting it? In my experience, it's always better to
do it like

TCPClient.Connect;
try
//do stuff
finally
TCPClient.Disconnect;
end;

--
Best regards :)

Guillem Vicens
Dep. informática Green Service SA
[email]guillemvicens (AT) clubgreenoasis (DOT) com[/email]
www.clubgreenoasis.com

"js" <js (AT) someone (DOT) com> escribió en el mensaje
news:4237b567$1 (AT) newsgroups (DOT) borland.com...
Quote:
hi, I have a kylix application use TCPClient to connect to a remote linux
server application in the Main thread:
if Not TCPClient.Connected then
begin
TCPClient.Host:= xxx;
TCPClient.Port:= xxx;
TCPClient.Connect(300);
end;
I found usually after 400 connections made, and the application would
hang.
The call stack was show as it stops in the Connect statement (and some
waitfor statement in CPU debug window), the main thread is dead; only
allow me to run few instructions in CPU debug window.
I already specify 300 ms timeout value, why still cause dead lock? Any
thought about this? Please help...



Back to top
JS
Guest





PostPosted: Wed Mar 16, 2005 4:53 pm    Post subject: Re: dead lock Reply with quote



Thanks Guillem,

Quote:
do it like

TCPClient.Connect;
try
//do stuff
finally
TCPClient.Disconnect;
end;


my code is, do you see any problem? also what the diff if I assign
"localhost" to TCPClient.Host? Thanks.
begin
try
if not TCPClient.Connected then
begin
TCPClient.Host := xxx; -> a number
TCPClient.Port := xxx; -> a number
TCPClient.Connect(500);
end;
//do stuff
TCPClient.Disconnect;
except
on E: Exception do
begin
if TCPClient.Connected then TCPClient.Discounnect;
//Logging
end;
end;





Back to top
Guillem
Guest





PostPosted: Thu Mar 17, 2005 12:34 pm    Post subject: Re: dead lock Reply with quote


"JS" <JS (AT) SomeOnehotmail (DOT) com> escribió en el mensaje
news:42386480 (AT) newsgroups (DOT) borland.com...

Quote:
also what the diff if I assign "localhost" to TCPClient.Host?

Assigning "localhost" to TCPClient.Host is equivalent to assign 127.0.0.1
(i.e. universal localhost IP). In fact, you can simply assign the name of
the computer in the network if you know it. For example, if you've got a LAN
with a computer Comp1 that has as IP 192.168.0.1, then assigning Comp1 to
Host is the same as assign 192.168.0.1. The name is resolved to obtain the
IP.

Quote:
begin
try
if not TCPClient.Connected then
begin
TCPClient.Host := xxx; -> a number
TCPClient.Port := xxx; -> a number
TCPClient.Connect(500);
end;
//do stuff
TCPClient.Disconnect;
except
on E: Exception do
begin
if TCPClient.Connected then TCPClient.Discounnect;
//Logging
end;
end;


not a problem, but i would suggest you to code it like this:

if not TCPClient.Connected then
begin
TCPClient.Host := xxx; -> a number
TCPClient.Port := xxx; -> a number
TCPClient.Connect(500);
end;
try
//do stuff
finally
TCPClient.Disconnect;
end;

As long as you are giving correct values (by that i mean format-correct, not
real ones) to Host and Port it should work fine. Also, i don't know how your
code looks like, but if Host and/or Port are always the same then i would
set them on design time using the object inspector and change the whole if
to just

if not TCPclient.Connected then TCPClient.Connect(500);
--
Best regards :)

Guillem Vicens
Dep. informática Green Service SA
[email]guillemvicens (AT) clubgreenoasis (DOT) com[/email]
www.clubgreenoasis.com



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.