-
The Multi-Session API
I am new to c++ network programming.
I have the case that there is web server connected to the application gateway through VPN. In the web server, I have the c++ scripts as below. I want to create multiple sessions and one session per thread and share some variables among these sessions. What the code should be then?
Code:
void APITest()
{
/* some global variables declared here*/
/* Start Thread 1 * /
/* Start Session 1 and call function which manipulate some global variables * /
/* Start Thread 2 * /
/* Start Session 2 and call function which handle some global variables * /
}
-
Cprogramming.com homework policy.
Google it.
-
I have find it in here
-
The link you posted is definitely *not* the way to go about learning how to do it. Taking random snippets of code and trying to piece them together is a complete waste of time. Find a good book/website on concurrency that goes over all of the different aspects and issues of writing multithreaded apps. The more (and the more detailed), the better. Read all of the documentation on the API's you plan to use.
One more thing - don't use CreateThread, it has memory-leak issues. Use the pthreads library, or at the very least _beginthreadex.