Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 19th, 2004, 5:34 PM   #11
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Of course not - take your time. I'm not paying you - I realise you're giving up your own free time to take a look.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 19th, 2004, 7:00 PM   #12
Eggbert
Professional Programmer
 
Eggbert's Avatar
 
Join Date: Nov 2004
Posts: 250
Rep Power: 5 Eggbert is on a distinguished road
Let's do this a bit differently, because your code has problems that keep me from getting the same error. Send me your project files so that I can get an exact duplicate of what you're seeing. That's much easier than me trying to wade my way through problematic code given as individual files but meant to be used as a whole.
Eggbert is offline   Reply With Quote
Old Nov 20th, 2004, 8:36 AM   #13
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Gotcha. Sorry for all the trouble this is taking. I'm using Visual C++ .NET - the project's at http://80.1.252.217/Sockets2.zip. If you replace the calls to server() or client() with the CreateThread function, it fails to build.

Thanks for the help.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 20th, 2004, 9:18 AM   #14
Eggbert
Professional Programmer
 
Eggbert's Avatar
 
Join Date: Nov 2004
Posts: 250
Rep Power: 5 Eggbert is on a distinguished road
Ah, so much easier. The problem is a declaration mismatch. LPTHREAD_START_ROUTINE is defined with the following tag:
typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(LPVOID lpThreadParameter);
Which, when we take out all of the fluff, becomes this:
typedef unsigned long (*PTHREAD_START_ROUTINE)(void *arg);
Take out the typedef and pointer to function, then change PTHREAD_START_ROUTINE to server and this is the result:
unsigned long server(void *arg);
Your actual server function is declared as
int server(void);
So the declarations don't match up. You could use a cast and hope for the best:
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)server, &dwThrdParam, 0, &dwThreadID);
Or you could do some research as to why LPTHREAD_START_ROUTINE uses that declaration then decide to either use a cast (if it's safe), or change client and server to do what they're supposed to. I won't make a recommendation because it's beneficial for you if you go through the research steps.

By the way, your program has bugs. Most notable is this one:
int Socket::error(const char *msg) {
 int errNo = (long)WSAGetLastError();
 std::cout << "Error #" << errNo << ": " << msg << std::endl;
 //
 // Comparing pointers, not strings. This wasn't intended.
 //
 if (msg != "WSAStartup")
  WSACleanup();
	
 return errNo;
}
So you'll want to put on your evil debugger hat and throw any trust in the code away until you've rooted all of the nasties out. Preferrably before you start adding threading code to the application.
Eggbert is offline   Reply With Quote
Old Nov 20th, 2004, 10:13 AM   #15
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Alright - thanks very much for the help. Hopefully it'll be done by tomorrow.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:00 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC