Nostradamus
December 29th, 2004, 07:24 AM
i use , multithread for multi client .. but i don't know how to handle when Onreceive() trigger(Csocket) on a thread
|
Click to See Complete Forum and Search --> : how ?? Nostradamus December 29th, 2004, 07:24 AM i use , multithread for multi client .. but i don't know how to handle when Onreceive() trigger(Csocket) on a thread menny_ed December 29th, 2004, 08:33 AM if you can get a pointer to the socket (which raised the event), you can use that pointer value (a pointer is actually a unsigned long) to store needed information in a global map. something like: ****************8 std::map<UNLOG, MyInfoStruct> a_map; .. .. .. OnReceive() { CSocket * s = get_event_sender(); MyInfoStruct info = a_map[(ULONG)s]; .. do the job .. } ************** You need to implement the 'get_event_sender();' function. i.e., when using IOCompletionPort, you get the socket which raised the event. Nostradamus January 3rd, 2005, 06:07 AM i use AfxBeginThread to create a thread. i need UINT MyClientThread( LPVOID pParam ); to put into AfxBeginThread. In my program. OnAccept function is like this : m_pCSocket = new CClientSocket(this); // CCLientSOcket is CSocket base class. m_pLSocket->Accept(*m_pCSocket); How to put it into thread... ??? Andreas Masur January 3rd, 2005, 06:40 AM [ Merged threads ] codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |