Click here to Skip to main content
15,914,221 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: "No appropriate constructor available" Pin
Steve S19-Aug-03 21:59
Steve S19-Aug-03 21:59 
GeneralRe: "No appropriate constructor available" Pin
adaoja19-Aug-03 22:23
adaoja19-Aug-03 22:23 
GeneralRe: "No appropriate constructor available" Pin
David Crow20-Aug-03 2:28
David Crow20-Aug-03 2:28 
GeneralSpy++ can not capture message of this window Pin
Shawn Ning19-Aug-03 10:10
Shawn Ning19-Aug-03 10:10 
GeneralRe: Spy++ can not capture message of this window Pin
HPSI19-Aug-03 11:11
HPSI19-Aug-03 11:11 
GeneralWebcam with MFC Pin
MKlucher19-Aug-03 10:10
MKlucher19-Aug-03 10:10 
GeneralRe: Webcam with MFC Pin
HPSI19-Aug-03 11:16
HPSI19-Aug-03 11:16 
Generalerasing a list entry Pin
Kuniva19-Aug-03 8:32
Kuniva19-Aug-03 8:32 
I made a class to manage a list of connections to my server, u can call AddConnection and RemoveConnection to add or remove a connection given the socket handle and/or thread handle.
This is the struct that contains all the data for each connection so far:
struct ClientConnection
{
    HANDLE hThread;
    SOCKET s;

    ClientConnection(): hThread(NULL),s(INVALID_SOCKET)
    {

    }
    ~ClientConnection()
    {

    }
};


then i define a type like this:
typedef list <ClientConnection*> CL;
typedef CL::iterator CLI;

and declare a new private variable in my class like this:
CL cl;


Now the code to remove a connection from the list is this:
void ConnectionManager::RemoveConnection(SOCKET _sd)
{
    CLI cli;
	for ( cli = cl.begin(); cli != cl.end(); ++ cli )
	{
        if((*cli)->s==_sd)
        {
            cl.erase(cli);
            //delete (*cli);
        }
	}
}


But for some reason the program crashes when it tries to erase the entry in the list... And i dont know why, if i just delete it, then it works fine but then the entry isnt actually gone. How do i get rid of the entry??? so that for example if i have 3 connections and i remove the 2nd, the 3'rd one will take the seconds place in the list?..

Thanks

Kuniva
--------------------------------------------
GeneralNVM Pin
Kuniva19-Aug-03 10:07
Kuniva19-Aug-03 10:07 
GeneralRe: NVM Pin
David Crow19-Aug-03 10:18
David Crow19-Aug-03 10:18 
GeneralRe: NVM Pin
Kuniva19-Aug-03 13:46
Kuniva19-Aug-03 13:46 
Questionresource.h ??? Pin
Max Santos19-Aug-03 7:55
Max Santos19-Aug-03 7:55 
AnswerRe: resource.h ??? Pin
Steve S19-Aug-03 21:57
Steve S19-Aug-03 21:57 
GeneralRe: resource.h ??? Pin
Max Santos20-Aug-03 1:20
Max Santos20-Aug-03 1:20 
GeneralImport a class from .DLL Pin
CND19-Aug-03 7:41
CND19-Aug-03 7:41 
GeneralRe: Import a class from .DLL Pin
John M. Drescher19-Aug-03 7:50
John M. Drescher19-Aug-03 7:50 
GeneralRe: Import a class from .DLL Pin
CND19-Aug-03 8:21
CND19-Aug-03 8:21 
GeneralRe: Import a class from .DLL Pin
igor196019-Aug-03 10:04
igor196019-Aug-03 10:04 
GeneralRe: Import a class from .DLL Pin
Anonymous19-Aug-03 10:13
Anonymous19-Aug-03 10:13 
GeneralWierd wierd multimedia timers Pin
Jon Hulatt19-Aug-03 6:40
Jon Hulatt19-Aug-03 6:40 
GeneralRe: Wierd wierd multimedia timers Pin
stephen.hazel19-Aug-03 7:07
stephen.hazel19-Aug-03 7:07 
GeneralCreateDIBBitmap in Windows2000 Server Pin
sdfdsfa19-Aug-03 6:37
sdfdsfa19-Aug-03 6:37 
GeneralOnNotify and the MFCGrid Pin
John Oliver19-Aug-03 6:27
John Oliver19-Aug-03 6:27 
GeneralRe: OnNotify and the MFCGrid Pin
HPSI19-Aug-03 6:39
HPSI19-Aug-03 6:39 
GeneralRe: OnNotify and the MFCGrid Pin
John Oliver19-Aug-03 6:48
John Oliver19-Aug-03 6:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.