Send and Receive Problem
-
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..
-
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..
-
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..
... 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] -
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.
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
-
... 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]not understand..
-
not understand..
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).
-
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
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.
-
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..
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