Question about creating threads
I was a little confused after reading the stuff on MSDN about CreateThread, ThreadProc etc.
1. When I create a thread, does it keep running over and over until ExitThread is called, or does returning any value kill it? The only one I've seen in action used a while(1) infinite loop and apparently returned when done or on error.
2. After calling CreateThread, can you call the ThreadProc(&lpParameter) to send it commands etc, just as if you were calling SendMessage on a callback for a window? I kind of wondered why that's a single pointer instead of allowing you to declare the ThreadProc with whatever vars you want it to receive (like window callbacks get HWND, MSG, LPARAM, WPARAM).
Basically, what I'd like to do is create a client thread for a winsock app to connect, if necessary reconnect, and handle sending/receiving socket data. It's a single connection that should stay open as long as the app is running, but if the other side is disconnected for some reason it needs to keep trying to reconnect. The reason for keeping it a separate thread is mainly that some of the data being transferred can take a long time. I suppose it's similar to writing an FTP app, but this is always connecting to the same place, automatically.