Results 1 to 7 of 7

Thread: winsock threads

  1. #1

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    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.

  2. #2

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    could i just get a link to a good tutorial on threads? thanks
    Amon Ra
    The Power of Learning.

  3. #3
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    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
    }

  4. #4

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    would it just be the same for a windows program?
    Amon Ra
    The Power of Learning.

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  6. #6

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    yea, i know..lol..i was just talking about programs with WinMain and WndProc..but ok..thanks
    Amon Ra
    The Power of Learning.

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width