Click here to Skip to main content
15,921,793 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: File conversion - base code or design pattern available? Pin
Christian Graus3-Dec-03 11:06
protectorChristian Graus3-Dec-03 11:06 
GeneralRe: File conversion - base code or design pattern available? Pin
Tom Archer3-Dec-03 13:13
Tom Archer3-Dec-03 13:13 
GeneralRe: File conversion - base code or design pattern available? Pin
Christian Graus3-Dec-03 13:18
protectorChristian Graus3-Dec-03 13:18 
GeneralRe: File conversion - base code or design pattern available? Pin
Tom Archer3-Dec-03 13:21
Tom Archer3-Dec-03 13:21 
GeneralRe: File conversion - base code or design pattern available? Pin
Nick Parker3-Dec-03 15:36
protectorNick Parker3-Dec-03 15:36 
GeneralRe: File conversion - base code or design pattern available? Pin
Christian Graus3-Dec-03 15:43
protectorChristian Graus3-Dec-03 15:43 
AnswerRe: File conversion - base code or design pattern available? Pin
Ravi Bhavnani3-Dec-03 11:13
professionalRavi Bhavnani3-Dec-03 11:13 
GeneralRe: File conversion - base code or design pattern available? Pin
Christian Graus3-Dec-03 11:51
protectorChristian Graus3-Dec-03 11:51 
GeneralRe: File conversion - base code or design pattern available? Pin
Tom Archer3-Dec-03 13:16
Tom Archer3-Dec-03 13:16 
GeneralRe: File conversion - base code or design pattern available? Pin
Tom Archer4-Dec-03 7:14
Tom Archer4-Dec-03 7:14 
GeneralDelta on libs Pin
Joe Woodbury3-Dec-03 10:14
professionalJoe Woodbury3-Dec-03 10:14 
GeneralRe: Delta on libs Pin
Ian Darling3-Dec-03 10:20
Ian Darling3-Dec-03 10:20 
GeneralRe: Delta on libs Pin
Joe Woodbury3-Dec-03 12:46
professionalJoe Woodbury3-Dec-03 12:46 
GeneralAnother InsertColumn question Pin
ns3-Dec-03 9:40
ns3-Dec-03 9:40 
GeneralRe: Another InsertColumn question Pin
David Crow3-Dec-03 10:25
David Crow3-Dec-03 10:25 
GeneralRe: Another InsertColumn question Pin
ns4-Dec-03 1:54
ns4-Dec-03 1:54 
GeneralRe: Another InsertColumn question Pin
ns4-Dec-03 3:13
ns4-Dec-03 3:13 
GeneralRe: Another InsertColumn question Pin
David Crow4-Dec-03 4:01
David Crow4-Dec-03 4:01 
QuestionReference to Variables? Pin
ypo_cnihtmarcher3-Dec-03 9:25
ypo_cnihtmarcher3-Dec-03 9:25 
AnswerRe: Reference to Variables? Pin
Christian Graus3-Dec-03 9:36
protectorChristian Graus3-Dec-03 9:36 
GeneralRe: Reference to Variables? Pin
GeMe_Hendrix3-Dec-03 11:36
GeMe_Hendrix3-Dec-03 11:36 
GeneralRe: Reference to Variables? Pin
Christian Graus3-Dec-03 11:39
protectorChristian Graus3-Dec-03 11:39 
GeneralInsertColumn ordering Pin
ns3-Dec-03 9:16
ns3-Dec-03 9:16 
GeneralRe: InsertColumn ordering Pin
David Crow3-Dec-03 10:38
David Crow3-Dec-03 10:38 
GeneralDebug assertion failed dbgheap.c! :( Pin
Kuniva3-Dec-03 9:04
Kuniva3-Dec-03 9:04 
Hi, i'm trying to write a multithreaded TCP server and it seemed to work ok now but suddenly i got this assertion error! The thing is, to test the server i connect with the windows 98 telnet application to my server. The clienthandler threads of my server continously check with select() if there is something to read on the socket. This gives me the oportunity to also check if the socket handle is not INVALID_SOCKET, since we might set it to this from somewhere else if we would like to "boot" the client and make sure the thread terminates. I get the assertion error in a number of particular cases, these are the two most common:
When i connect via telnet, type some text, then connect another one, also type some text, and then i close the first one without disconnecting properly, also the server does not see it is disconnected.
Or, when i connect, type some text, close telnet without disconnecting, and reconnect.

After these two situations it always gives me the error "Debug Assertion failed" in dbgheap.c.
This is part of my code:

DWORD WINAPI ClientHandler(void* prms)
{
	ClientInfo * clinfo = (struct ClientInfo*)prms;
	SOCKET sd = (SOCKET)clinfo->SocketHandle;

	char buffer[1024];
	int nRead = 0;
	BOOL abort = FALSE;

	do
	{
		if(sd!=INVALID_SOCKET && IsSocketReadyToRead(sd,50))
		{
			nRead = recv(sd, buffer, sizeof(buffer), 0);
			if(nRead==0)
			{
				abort = TRUE;
			}
		}
	}
	while(!abort);

	RemoveConnection(sd);

	return 0;
}

ClientInfo is just a struct with some information about each client (socket handle, thread handle, etc..)

This is what IsSocketReadyToRead() looks like:
BOOL IsSocketReadyToRead(SOCKET s, int timeout)
{
    int retval;
    fd_set* socketset;

    socketset = new fd_set;
	FD_ZERO(socketset);
	FD_SET(s, socketset);

    if( timeout!=0 )
    {
        struct timeval time;
		memset(&time,0,sizeof(struct timeval));
        time.tv_sec = 0;
        time.tv_usec = (long)timeout;
        retval = select( 0, socketset, NULL, NULL, &time );
    }
    else
    {
        struct timeval time = { 0, 0 };
        retval = select( 0, socketset, NULL, NULL, &time );
    }

	delete socketset;

	switch(retval)
	{
	case 1:
		return TRUE;
		break;
	case 0:
		return FALSE;
		break;
	case SOCKET_ERROR:
		return FALSE;
		break;
	default:
		return FALSE;
	}
}


The RemoveConnection function does not matter seeings in neither of the situations it is called.

Does anyone have any idea what might be causing this?
Oh yes btw, i also, at other times, in the same situation, did not get the assertion error, but a memory error where it gave me that "the memory could not be written." and the contents of a pointer. But i don't know if its my app or the underlying framework. Thanks for any help, if you would like to see more code, just ask.

Kuniva
--------------------------------------------

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.