Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem in making multithreading Winsock Server

Problem in making multithreading Winsock Server

Scheduled Pinned Locked Moved C / C++ / MFC
helpsysadmindebuggingquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nachilau
    wrote on last edited by
    #1

    Hello, I am changing my server to support multithreading. However, I have problem. This is how the server main loop is //###################################################################### // Main Server loop CSocket clientS; while (run) { Print_Log("A loop... : mainServer->Start()"); cs.Accept(clientS); hSThread = CreateThread(NULL, 0, ServiceThread, &clientS, 0, &threadId); } // end while...loop //###################################################################### Here is my thread call back function: DWORD WINAPI ServiceThread(LPVOID p) { CSocket* clientS = ((CSocket*)p); int re; char r[6]; do { re = clientS->Receive(r, 6); if (re != 0) cout << r << endl; } while (re != 0); clientS->Close(); return 0; } // end of function ServiceThread() I get a error message when the client send me somehing, which is "Debug Assertion Fail". The server can actually receive the message, but when the thread is going to close. The error message come out. I didn't know where my code have make the mistake. Can anyone help me? Thanks! Nachi X|

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups