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. Send and Receive Problem

Send and Receive Problem

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
8 Posts 5 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.
  • U Offline
    U Offline
    User 3650979
    wrote on last edited by
    #1

    hi friends, i develop one protocol in MFC...i am using CSocket. main thread is Listen Thread..its ok fine.. in this thread all the client Handler stored in map..another two subthreads is Requestthread and Reponsethread.. Reponse thread sending Data to clients.. and Requestthread want recieve acknowledgement... i want send and recieve Continuesly existing clients.... i am facing problem childthreads...please any body...ugrent..

    L C D 3 Replies Last reply
    0
    • U User 3650979

      hi friends, i develop one protocol in MFC...i am using CSocket. main thread is Listen Thread..its ok fine.. in this thread all the client Handler stored in map..another two subthreads is Requestthread and Reponsethread.. Reponse thread sending Data to clients.. and Requestthread want recieve acknowledgement... i want send and recieve Continuesly existing clients.... i am facing problem childthreads...please any body...ugrent..

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Member 3653751 wrote:

      i am facing problem childthreads...please any body...ugrent..

      Perhaps you could tell us exactly what problem you are facing, we cannot guess.

      It's time for a new signature.

      U 1 Reply Last reply
      0
      • U User 3650979

        hi friends, i develop one protocol in MFC...i am using CSocket. main thread is Listen Thread..its ok fine.. in this thread all the client Handler stored in map..another two subthreads is Requestthread and Reponsethread.. Reponse thread sending Data to clients.. and Requestthread want recieve acknowledgement... i want send and recieve Continuesly existing clients.... i am facing problem childthreads...please any body...ugrent..

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        ... Stay tuned... Now booting Mystical Powers... :rolleyes:

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        U 1 Reply Last reply
        0
        • L Lost User

          Member 3653751 wrote:

          i am facing problem childthreads...please any body...ugrent..

          Perhaps you could tell us exactly what problem you are facing, we cannot guess.

          It's time for a new signature.

          U Offline
          U Offline
          User 3650979
          wrote on last edited by
          #4

          hi friend, After sending i want wait for acknowledgement(RecieveThread). Sendthread and recievethread individual Threads... Example: 1. 10 clients connected to my Communicator.... 2. I want to take associated client information(packets) from database i.e 10 or 100 packets i want sent proper client and wait for acknowledgment. After receiving acknowledgment i want sent another packet to corresponding client. 3. i want to all the clients like this... note : Socket Handler stored in Map; UINT RecieveThread(LPVOID pParam) { AfxSocketInit(); CSolusServerDlg *Dlg= (CSolusServerDlg*)pParam; bool bRun = true; SOCKET * pCurrentHandle; CSocket pSocket; char pBuf[4096]; CWinThread * pCurrentThread; pCurrentThread = AfxGetThread(); pCurrentHandle = &hClinetHandle; pSocket.Attach(hClinetHandle); for(int i=0;i<4096;i++) pBuf[i] = '\0'; int len; while(bRun) { if(pSocket.Receive(pBuf,4096)>0) { len = sizeof(pBuf); for( int i=0; i<len; i++ ) Dlg->ActionScanReceivedByte(pBuf[i]); } } CliThreadList.RemoveAt(CliThreadList.Find(pCurrentThread)); pSocket.ShutDown(2); pSocket.Close(); CliHandleList.RemoveAt(CliHandleList.Find(pCurrentHandle)); return 0; } UINT Sendthread(LPVOID pParam) { AfxSocketInit(); CSolusServerDlg *Dlg= (CSolusServerDlg*)pParam; bool bRun = true; SOCKET * pCurrentHandle; CSocket pSocket; char pBuf[4096]; CWinThread * pCurrentThread; pCurrentThread = AfxGetThread(); pCurrentHandle = &hClinetHandle; pSocket.Attach(hClinetHandle); vecUploadValues AcfManagementData; for(int i=0;i<4096;i++) pBuf[i] = '\0'; int len; FILE *fpUpload; char date [10]; char time [15]; SYSTEMTIME st; char* CStrTrim = new char[1024]; unsigned char *l_uca_Buffer; unsigned char l_uca_ActualData[1024]; unsigned char l_uca_Buffer1[2048]; unsigned char *cConverationBuffer; CString strTemp; char cstrTemp[512]; CDBFile objDB; CSocket *pSocketSent; while(bRun) { for(IteratorMap = mapControllerHandler.begin(); IteratorMap != mapControllerHandler.end() ;IteratorMap++) { char strControllerID[10]; char strControllerIID[10]; int ControllerId = (*IteratorMap).first; sprintf(strControllerID,"%06d ", ControllerId); memset(strControllerIID,0,sizeof(strControllerIID)); objDB.GetControllerID(strCo

          L 1 Reply Last reply
          0
          • C CPallini

            ... Stay tuned... Now booting Mystical Powers... :rolleyes:

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            U Offline
            U Offline
            User 3650979
            wrote on last edited by
            #5

            not understand..

            I 1 Reply Last reply
            0
            • U User 3650979

              not understand..

              I Offline
              I Offline
              Iain Clarke Warrior Programmer
              wrote on last edited by
              #6

              He has to use mystical powers, because you didn't include any information about your problem. But you replied with more information to Richard. Please read the "How to ask questions" post at the top of the forum for more instructions on how to ask a good question. A good question will get better replies. Good luck with your problems, Iain.

              I have now moved to Sweden for love (awwww).

              1 Reply Last reply
              0
              • U User 3650979

                hi friend, After sending i want wait for acknowledgement(RecieveThread). Sendthread and recievethread individual Threads... Example: 1. 10 clients connected to my Communicator.... 2. I want to take associated client information(packets) from database i.e 10 or 100 packets i want sent proper client and wait for acknowledgment. After receiving acknowledgment i want sent another packet to corresponding client. 3. i want to all the clients like this... note : Socket Handler stored in Map; UINT RecieveThread(LPVOID pParam) { AfxSocketInit(); CSolusServerDlg *Dlg= (CSolusServerDlg*)pParam; bool bRun = true; SOCKET * pCurrentHandle; CSocket pSocket; char pBuf[4096]; CWinThread * pCurrentThread; pCurrentThread = AfxGetThread(); pCurrentHandle = &hClinetHandle; pSocket.Attach(hClinetHandle); for(int i=0;i<4096;i++) pBuf[i] = '\0'; int len; while(bRun) { if(pSocket.Receive(pBuf,4096)>0) { len = sizeof(pBuf); for( int i=0; i<len; i++ ) Dlg->ActionScanReceivedByte(pBuf[i]); } } CliThreadList.RemoveAt(CliThreadList.Find(pCurrentThread)); pSocket.ShutDown(2); pSocket.Close(); CliHandleList.RemoveAt(CliHandleList.Find(pCurrentHandle)); return 0; } UINT Sendthread(LPVOID pParam) { AfxSocketInit(); CSolusServerDlg *Dlg= (CSolusServerDlg*)pParam; bool bRun = true; SOCKET * pCurrentHandle; CSocket pSocket; char pBuf[4096]; CWinThread * pCurrentThread; pCurrentThread = AfxGetThread(); pCurrentHandle = &hClinetHandle; pSocket.Attach(hClinetHandle); vecUploadValues AcfManagementData; for(int i=0;i<4096;i++) pBuf[i] = '\0'; int len; FILE *fpUpload; char date [10]; char time [15]; SYSTEMTIME st; char* CStrTrim = new char[1024]; unsigned char *l_uca_Buffer; unsigned char l_uca_ActualData[1024]; unsigned char l_uca_Buffer1[2048]; unsigned char *cConverationBuffer; CString strTemp; char cstrTemp[512]; CDBFile objDB; CSocket *pSocketSent; while(bRun) { for(IteratorMap = mapControllerHandler.begin(); IteratorMap != mapControllerHandler.end() ;IteratorMap++) { char strControllerID[10]; char strControllerIID[10]; int ControllerId = (*IteratorMap).first; sprintf(strControllerID,"%06d ", ControllerId); memset(strControllerIID,0,sizeof(strControllerIID)); objDB.GetControllerID(strCo

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Member 3653751 wrote:

                please help anybody...

                Well you have still not explained what is not working, or giving incorrect results. Also would you please edit the above message and put <pre></pre> tags around your code so it is properly readable.

                It's time for a new signature.

                1 Reply Last reply
                0
                • U User 3650979

                  hi friends, i develop one protocol in MFC...i am using CSocket. main thread is Listen Thread..its ok fine.. in this thread all the client Handler stored in map..another two subthreads is Requestthread and Reponsethread.. Reponse thread sending Data to clients.. and Requestthread want recieve acknowledgement... i want send and recieve Continuesly existing clients.... i am facing problem childthreads...please any body...ugrent..

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  Member 3653751 wrote:

                  i want send and recieve Continuesly

                  So then shouldn't you be using CAsyncSocket instead? See here for more.

                  "One man's wage rise is another man's price increase." - Harold Wilson

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  "Man who follows car will be exhausted." - Confucius

                  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