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. Thread Creation / Server

Thread Creation / Server

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++sysadmin
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.
  • B Offline
    B Offline
    brilliant101
    wrote on last edited by
    #1

    1)I converted the MFC TCP server into non mfc TCP server using winsock.h. It complies and runs but it does not performs efficiently as the server thread is not created properly in the non mfc statment of _beginthread and CreateThread Plz modify the code so that it runs smoothly thanks 2) what i have to do to make UDP server? 3) how can i change it into mutithreaded server( that accpets connections from many threads?) #include process.h #include windows.h #include iostream.h #include conio.h #include winsock2.h /* _beginthread, _endthread */ #include stddef.h #include stdlib.h unsigned int ServerThread(LPVOID pParam); int main(int argc, char* argv[]) { HANDLE hThread; unsigned long iID; cout<<"!!hello world!!\n"; LPVOID var=0; //unsigned int block=0; //block=ServerThread(var); //Call to the function // _beginthreadex( ServerThread, 0, NULL ); hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE )ServerThread,NULL,0,&iID); //_beginthread(ServerThread, 0, NULL ); // hThread = (HANDLE)_beginthreadex( NULL, 0, &ServerThread, NULL, 0, // &iID ); cout<<"\n\nyahoo"; // while(getch()!=27); // getch(); return 0; } unsigned int ServerThread(LPVOID pParam) { cout<<"Hello from thread"; SOCKET server; //Socket is unsigned int WSADATA wsaData; sockaddr_in local; // Structure variable int wsaret=WSAStartup(0x101,&wsaData); //Initialization if(wsaret!=0) { return 0; }

    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