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 

No Event executed

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Christian Bode
Guest





PostPosted: Sun Feb 22, 2004 12:59 am    Post subject: No Event executed Reply with quote



Hi,

After i called
"TIdIOHandlerSocket(TIdTCPServer.Threads.LockList[0]).Binding.PeerIP;" in
the OnDisconnect event the peer is able to connect but no event will be
triggered on server side. why, what's going on here ? I've tried
"TIdIOHandlerSocket(AThread.Connection.IOHandler).Binding.PeerIP;" and it
works fine. What exactly is the function of LockList ?

thx
Christian


Back to top
Rob Kennedy
Guest





PostPosted: Sun Feb 22, 2004 4:35 am    Post subject: Re: No Event executed Reply with quote



Christian Bode wrote:
Quote:
After i called
"TIdIOHandlerSocket(TIdTCPServer.Threads.LockList[0]).Binding.PeerIP;" in
the OnDisconnect event the peer is able to connect but no event will be
triggered on server side. why, what's going on here ? I've tried
"TIdIOHandlerSocket(AThread.Connection.IOHandler).Binding.PeerIP;" and it
works fine. What exactly is the function of LockList ?

It locks the list. This is just a guess, but I suspect that
TIdTCPServer.Threads is a TThreadList. Read about it in the help. Pay
particular attention to the UnlockList method.

Indy has a news server of its own. You might find find more
knowledgeable folks to answer your questions there. See the support page
at Indy's Web site for more information.

--
Rob

Back to top
Christian Bode
Guest





PostPosted: Sun Feb 22, 2004 8:58 pm    Post subject: Re: No Event executed Reply with quote



Quote:
It locks the list. This is just a guess, but I suspect that
TIdTCPServer.Threads is a TThreadList. Read about it in the help. Pay
particular attention to the UnlockList method.

Ok, i've done. But there is another problem i don't unstand.

at the first time i've used the following:

for I := 0 to TCPWinServer.Threads.LockList.Count-1 do begin
if
TidPeerThread(TCPWinServer.Threads.LockList.Items[I]).Connection.Connected
then

TidPeerThread(TCPWinServer.Threads.LockList.Items[I]).Connection.WriteLn(Wri
teRP_Packet(37, 'empty'));
end;
TCPWinServer.Threads.UnlockList;

But this causes the same problem like without the unlock function. The
OnExcecuteEvent will not be triggered.
So i've used:

with TCPWinServer.Threads.LockList do begin
for I := 0 to Count-1 do begin
if TidPeerThread(Items[I]).Connection.Connected then
TidPeerThread(Items[I]).Connection.WriteLn(WriteRP_Packet(37,
'empty'));
end;
TCPWinServer.Threads.UnlockList;
end;

and it works perfectly. But why the hell ? If i see the source i believe i
could called locklist and unlocklist only once. Is that right ?

thx
Christian



Back to top
Rob Kennedy
Guest





PostPosted: Sun Feb 22, 2004 11:26 pm    Post subject: Re: No Event executed Reply with quote

Christian Bode wrote:
Quote:
with TCPWinServer.Threads.LockList do begin
for I := 0 to Count-1 do begin
if TidPeerThread(Items[I]).Connection.Connected then
TidPeerThread(Items[I]).Connection.WriteLn(WriteRP_Packet(37,
'empty'));
end;
TCPWinServer.Threads.UnlockList;
end;

and it works perfectly. But why the hell ? If i see the source i believe i
could called locklist and unlocklist only once. Is that right ?

The lock is implemented with a critical section, which can be entered
multiple times. You need to unlock the list the same number of times as
you lock it. Otherwise it will remain locked. (Trying to unlock a list
that's already unlocked leads to undefined behavior.)

The LockList method returns a normal TList object. Store that in a local
variable and use it instead of repeatedly calling LockList every time
you need to access the list. It's the same strategy as the "with" block
you used, but it avoids the ambiguity that "with" might introduce.

list := Threads.LockList;
try
for i := 0 to list.Count - 1 do begin
// etc.
end;
finally
Threads.UnlockList;
end;

For more examples of how to use LockList, search Classes.pas.

--
Rob

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc 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.