Error receiving message

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2008
Posts: 23
Reputation: wamuti is an unknown quantity at this point 
Solved Threads: 1
wamuti wamuti is offline Offline
Newbie Poster

Error receiving message

 
0
  #1
Feb 18th, 2008
Hi guyz. I am making a client-server application uysing CAnsySocket. A little history may help you assist. I made the application and was working just okay but the problem was that two client app. could not connect to the server. It always crashed. A viable solution to that was making a multi threaded server. Now, i have set worker threads for accepting the connection (For listening it is using the main thread). Below is the accepting code:

  1. OnAccept()
  2. {
  3. THREADPARAMS * pSocket; // THREADPARAMS is a structure defined in .h
  4. AfxBeginThread(AcceptFunc, pSocket);
  5. }
  6. UNIT AcceptFunc(LPARAM pParam)
  7. {
  8. THREADPARAMS * pSocket;
  9. pSocket->m_sServerSocket.Accept(m_sClientSocket);
  10. }
  11. //in my .h
  12. typedef struct THREADPARAMS
  13. {
  14. CMySocket m_sServerSocket, m_sClientSocket;
  15. }

the error is in line 9. The code is compiling just okay but when the client tries to connect the server crashes. Now, when i debug, it us taking me to line 9. Things to do with the parameters. I have trapped an error that i would expect if the client cannot locate the server but since that error is not popping, the server is listenning just okay, just the accepting part. Please assist me.
Last edited by WolfPack; Feb 18th, 2008 at 2:09 am. Reason: Corrected the Code tags. IF you use [CODE=cpp][/code] then you don't have to write line numbers in your code.
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 12
Reputation: dandan is an unknown quantity at this point 
Solved Threads: 1
dandan dandan is offline Offline
Newbie Poster

Re: Error receiving message

 
0
  #2
Feb 18th, 2008
  1. THREADPARAMS * pSocket;
  2. pSocket->m_sServerSocket.Accept(m_sClientSocket);

pSocket is not initialized. You need to assign a valid value first.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC