Urgent please, Iterators and Sockets

Hi,

I have a server app that listens for clients to connect, when they do so they are entered into a CTypedPtrList with their socket and username.

When this is done during the login, i want to be able to send all the clients a list of who is online which i have tried to do here but it only sends one username to each client which is their own name.

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

then a second variable buddylist is defined which is valid only within {} of the loop (scope);

Second, did you see the "+=" operator? That makes that your names get appended.

If you set a break point before the second loop you should see that 'buddylist' is properly filled with all names.

Hope, that helps

Alex

nikon70Author Commented: 2003-11-12

Have checked through the code and it is not doing what you think it does,

client 1 connects and gets its name,
client 2 connects and gets client 1's name, and client 1 gets its own name again.
then if client 3 connects it gets client 1's name and client 1 get its own and client 2 gets client 1 name...

That means you create a new instance of CConnUser and CConnSocket and that should be deleted if the user makes a logout. Then, the user pointer is stored to the list and this entry should be removed from list when logout (in order to show a correct buddylist if you get another login).

I will assume that CConnSocket is derived from CASyncSocket and that you have a handler CConnSocket::OnClose() that gets called when the user logouts. Then, you may get the pointer to the associated user and the pointer of CSockServerDlg where the m_ConnUserList is a member from your socket. Then, you may call the logout function of the dialog.