shaneholmes
asked on
TServerSocket's OnClientDisconnect ?
Why is it that I can't seem to get the OnClientDisconnect of the TServerSocket to report the coorect ActiveConnections?
I am simply creating a ListItem in my ListView for each connection on the OnClientConnect and then removing them in the OnClientDisconnect event - by using a UpdateClients method - see below, however, it doesn't seem to be working for the OnClientDisconnect event. - Any remedy?
procedure TfrmMain.sckMainClientConn ect(Sender : TObject;
Socket: TCustomWinSocket);
begin
pnlClients.Caption:= IntToStr(sckMain.Socket.Ac tiveConnec tions)+' Clients';
UpdateClients;
end;
procedure TfrmMain.sckMainClientDisc onnect(Sen der: TObject;
Socket: TCustomWinSocket);
begin
pnlClients.Caption:= IntToStr(sckMain.Socket.Ac tiveConnec tions-1)+' Clients';
UpdateClients;
end;
procedure TfrmMain.UpdateClients;
var
Item: TListItem;
I: Integer;
begin
lvwClients.Items.BeginUpda te;
lvwClients.Clear;
for I:= 0 to sckMain.Socket.ActiveConne ctions-1 do
begin
Item:= lvwClients.Items.Add;
Item.Caption:= sckMain.Socket.Connections [I].Remote Host;
end;
lvwClients.Items.EndUpdate ;
end;
I am simply creating a ListItem in my ListView for each connection on the OnClientConnect and then removing them in the OnClientDisconnect event - by using a UpdateClients method - see below, however, it doesn't seem to be working for the OnClientDisconnect event. - Any remedy?
procedure TfrmMain.sckMainClientConn
Socket: TCustomWinSocket);
begin
pnlClients.Caption:= IntToStr(sckMain.Socket.Ac
UpdateClients;
end;
procedure TfrmMain.sckMainClientDisc
Socket: TCustomWinSocket);
begin
pnlClients.Caption:= IntToStr(sckMain.Socket.Ac
UpdateClients;
end;
procedure TfrmMain.UpdateClients;
var
Item: TListItem;
I: Integer;
begin
lvwClients.Items.BeginUpda
lvwClients.Clear;
for I:= 0 to sckMain.Socket.ActiveConne
begin
Item:= lvwClients.Items.Add;
Item.Caption:= sckMain.Socket.Connections
end;
lvwClients.Items.EndUpdate
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
K, let me give that a try....btw, i left you a comment on my last post, regarding the Disabling Ctrl-Alt-Del in XP.
Would you please go back and view this and help me out with it.
Would you please go back and view this and help me out with it.
ASKER
Sorry about my last comment, it was not you who i left a comment for.
BTW, thanks for the perfect answer to my post!
Shane
BTW, thanks for the perfect answer to my post!
Shane
Geoff M.