|
-
Mar 22nd, 2002, 07:42 PM
#1
Thread Starter
Hyperactive Member
winsock threads
is there an example of how to create a thread in a winsock application listenning for incoming connections, while there is still the main thread working with the display of the data received...(basically a chat program)?
thanks in advance
Amon Ra
Amon Ra
The Power of Learning.
-
Mar 23rd, 2002, 08:25 PM
#2
Thread Starter
Hyperactive Member
could i just get a link to a good tutorial on threads? thanks
Amon Ra
The Power of Learning.
-
Mar 24th, 2002, 02:58 PM
#3
Frenzied Member
Set your project settings to Multithreading.
Code:
#inlcude <windows.h>
#include <process.h>
static void theadFunction (void *arguments) {
// Do Data Retrieval
_endthread();
}
void main (void) {
unsigned long threadID = _beginthread(threadFunction, 0, (void *)0);
if (threadID == -1) {
//Error
}
// Do Display
}
-
Mar 24th, 2002, 05:15 PM
#4
Thread Starter
Hyperactive Member
would it just be the same for a windows program?
Amon Ra
The Power of Learning.
-
Mar 24th, 2002, 07:10 PM
#5
Monday Morning Lunatic
That is a Windows program 
Apart from the different entry point, of course
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Mar 24th, 2002, 08:23 PM
#6
Thread Starter
Hyperactive Member
yea, i know..lol..i was just talking about programs with WinMain and WndProc..but ok..thanks
Amon Ra
The Power of Learning.
-
Apr 2nd, 2002, 11:22 AM
#7
It doesn't matter. It's still the same.
Don't call _endthread, just return from the function.
And if you want to do anything with the thread handle (like for eaxmple get the exit code of the thread) or do something advanced (start the thread suspended so you can adjust it's priority) you should use _beginthreadex.
If you don't use any runtime library functions, use CreateThread, it will save you resources.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|