
January 5th, 2005, 10:26 AM
|
 |
Contributing User
|
|
Join Date: Jan 2003
Location: USA
|
|
|
Covered in Multithreading 101.
You have a function that is run as a thread, CClientThread in your example.
It has a pre-defined parameter list; ie, that parameter list is predefined by the compiler and the declaration of your CClientThread function must comform to that definition.
The parameter of interest is a void pointer. That's the one that you use.
Take the address of the socket and cast it as a void pointer. Within CClientThread, cast its void pointer argument as a pointer to a socket and then use it.
If you have multiple parameters you want to pass into a thread, then declare a struct to contain all those parameters, create a struct variable and populate it, then pass a pointer to that struct variable cast as a void pointer.
Your help files should have examples of this. Yes, I know that it is not easy to look up specific info in VC++6 help. And if you're stuck with .NET, I found that that is not much better.
Question:
myListenSocket->Accept(*myClientSocket)
Is myClientSocket a pointer? If Accept() is written to return the new client socket through the parameter list, then why are you dereferencing that pointer?
Possibility: Is myClientSocket a socket type and you are trying to pass a pointer to it? In that case you need to use the address operator, &; ie:
myListenSocket->Accept(&myClientSocket);
Last edited by dwise1_aol : January 5th, 2005 at 10:38 AM.
|