Thread: multithreading with mswinsock?

  1. #1
    Unregistered
    Guest

    multithreading with mswinsock?

    does anyone has an example with multithreading on winsock?how to pass the socket on a thread...and everything else the socket handles?

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    HANDLE CreateThread(
    LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
    SIZE_T dwStackSize, // initial stack size
    LPTHREAD_START_ROUTINE lpStartAddress, // thread function
    LPVOID lpParameter, // thread argument

    DWORD dwCreationFlags, // creation option
    LPDWORD lpThreadId // thread identifier
    );
    The Bold param is there for you to pass a 32 bit value to a thread function....now this can be whatever, but usually its best to pass a pointer...

    Code:
    //Main
    SOCKET sock;
    
    //..................
    
    CreateThread(........., (LPVOID) &sock,.....);
    
    //..................
    
    }
    
    DWORD WINAPI ThreadProc(LPVOID lpParameter){
    
    SOCKET sock = (SOCKET)*lpParameter;
    
    //Use socket as you wish....
    
    }
    Last edited by Fordy; 07-19-2002 at 04:11 PM.

  3. #3
    Unregistered
    Guest
    In visual basic...please

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Err....ugh............I think you are in the wrong place............sorry

  5. #5
    Unregistered
    Guest
    does anyone knows another forum to post this question?
    for vb...

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Have a go @ programmer's heaven

  7. #7
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    vbforums.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multithreading (flag stopping a thread, ring buffer) volatile
    By ShwangShwing in forum C Programming
    Replies: 3
    Last Post: 05-19-2009, 07:27 AM
  2. multithreading in C++
    By manzoor in forum C++ Programming
    Replies: 19
    Last Post: 11-28-2008, 12:20 PM
  3. Question on Multithreading
    By ronan_40060 in forum C Programming
    Replies: 1
    Last Post: 08-23-2006, 07:58 AM
  4. Client/Server and Multithreading
    By osal in forum Windows Programming
    Replies: 2
    Last Post: 07-17-2004, 03:53 AM
  5. Multithreading
    By JaWiB in forum Game Programming
    Replies: 7
    Last Post: 08-24-2003, 09:28 PM