Click here to Skip to main content
15,918,624 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Pure virtual base class question Pin
CPallini7-Jul-11 3:14
mveCPallini7-Jul-11 3:14 
GeneralRe: Pure virtual base class question Pin
Maximilien7-Jul-11 3:32
Maximilien7-Jul-11 3:32 
QuestionRe: Pure virtual base class question Pin
CPallini7-Jul-11 10:27
mveCPallini7-Jul-11 10:27 
AnswerRe: Pure virtual base class question Pin
Niklas L7-Jul-11 20:46
Niklas L7-Jul-11 20:46 
GeneralRe: Pure virtual base class question Pin
CPallini7-Jul-11 21:14
mveCPallini7-Jul-11 21:14 
GeneralRe: Pure virtual base class question Pin
Niklas L7-Jul-11 21:53
Niklas L7-Jul-11 21:53 
AnswerRe: Pure virtual base class question Pin
Maximilien8-Jul-11 2:55
Maximilien8-Jul-11 2:55 
AnswerRe: Pure virtual base class question Pin
Erudite_Eric7-Jul-11 22:33
Erudite_Eric7-Jul-11 22:33 
GeneralRe: Pure virtual base class question Pin
Stefan_Lang10-Jul-11 22:40
Stefan_Lang10-Jul-11 22:40 
GeneralRe: Pure virtual base class question Pin
Erudite_Eric10-Jul-11 22:43
Erudite_Eric10-Jul-11 22:43 
Questionoperator overloading problem....... Pin
gateway236-Jul-11 20:01
gateway236-Jul-11 20:01 
AnswerRe: operator overloading problem....... PinPopular
Niklas L6-Jul-11 21:11
Niklas L6-Jul-11 21:11 
GeneralRe: operator overloading problem....... Pin
Stefan_Lang7-Jul-11 23:58
Stefan_Lang7-Jul-11 23:58 
GeneralRe: operator overloading problem....... Pin
Niklas L8-Jul-11 1:06
Niklas L8-Jul-11 1:06 
AnswerRe: operator overloading problem....... Pin
JanakiramanElumalai7-Jul-11 4:09
JanakiramanElumalai7-Jul-11 4:09 
QuestionWhat are the basic benefits of using mmioxxxx “file” functions as opposed to “plain “ MFC CFile? Pin
Vaclav_6-Jul-11 13:34
Vaclav_6-Jul-11 13:34 
AnswerRe: What are the basic benefits of using mmioxxxx “file” functions as opposed to “plain “ MFC CFile? Pin
Mark Salsbery6-Jul-11 13:43
Mark Salsbery6-Jul-11 13:43 
GeneralRe: What are the basic benefits of using mmioxxxx “file” functions as opposed to “plain “ MFC CFile? Pin
Vaclav_6-Jul-11 15:43
Vaclav_6-Jul-11 15:43 
QuestionIOCP again Pin
csrss6-Jul-11 8:34
csrss6-Jul-11 8:34 
AnswerRe: IOCP again Pin
cmk6-Jul-11 10:38
cmk6-Jul-11 10:38 
AnswerRe: IOCP again Pin
Mark Salsbery6-Jul-11 10:56
Mark Salsbery6-Jul-11 10:56 
Could only guess without seeing the code.

Some comments and random thoughts though...

The IOCP knows nothing about how many threads there are beyond how many are waiting on ::GetQueuedCompletionStatus().

There's no correlation between number of sockets (one for each client) associated with the IOCP and the number of worker threads. In fact, one thread per client is wrong and exactly what IOCPs are meant to eliminate.

So something is up in your code (obviously? Smile | :) ).

You can't share completion packets (OVERLAPPED structs) between sockets.
If the threads are accessing any common data objects then synchronization must be used.

For what it's worth, here's an example of an OVERLAPPED struct from one of my apps. Maybe it will spark something on your end...

Notes:
CClientConnection is a class that holds client information and also holds the socket handle and associated information.
pData is the I/O buffer, and is reallocated for each I/O operation. In my protocol I send a header of a known size first. That header has the number of following data bytes to expect.
dwDataLength and dwDataLengthProcessed are used tohandle situations where a single WSASend/WSARecv call doesn't process the total number of bytes requested. This MUST be done! There's no guarantee send and recv operations will send or receive all the bytes in one call. Successful completion could mean just a single byte!

// OVERLAPPEDOP_xxx used for overlapped IO

#define OVERLAPPEDOP_NOOP				0
#define OVERLAPPEDOP_SOCKACCEPT			1	// CompletionKey = SOCKET, pData  = 0
#define OVERLAPPEDOP_SOCKSEND			2	// CompletionKey = SOCKET, pData  = NETCOMMPACKET*
#define OVERLAPPEDOP_SOCKRECVHEADER		3	// CompletionKey = SOCKET, pData  = NETPACKETHEADER*
#define OVERLAPPEDOP_SOCKRECVPACKET		4	// CompletionKey = SOCKET, pData  = NETCOMMPACKET*
#define OVERLAPPEDOP_EXITTHREAD			5	// CompletionKey = 0

// MANAGEROP_xxx used for server manager thread operations

#define MANAGEROP_ADDCLIENTCONNECTION		1	// pData  = NEWUSERSOCKETINFO*
#define MANAGEROP_REMOVECLIENTCONNECTION	2	// lParam1 = CClientConnection*
#define MANAGEROP_REMOVEIOCPTHREAD			3	// lParam1 = CIOCPHandlerThread*
#define MANAGEROP_BROADCASTMESSAGE			4	// lParam1 = NETCOMMPACKETLITE* (alloc'd as BYTE*), lParam2 = CClientConnection* client to exclude

//-------------------------------------------------------------------------


#pragma pack( push, SRVRMGR_OVERLAPPEDpack, 1 )
//-------------------------------------------------------------------------
struct SRVRMGR_OVERLAPPED
//-------------------------------------------------------------------------
{
	OVERLAPPED Overlapped;

	DWORD dwOpCode;    // OVERLAPPEDOP_xxxx and MANAGEROP_xxxx codes defined above
	CClientConnection *pClientConnection;
	LPARAM	lParam1;
	LPARAM	lParam2;
	DWORD dwDataLength;
	DWORD dwDataLengthProcessed;
	BYTE *pData;

	SRVRMGR_OVERLAPPED()  {memset(this, 0, sizeof(SRVRMGR_OVERLAPPED));}
};
#pragma pack( pop, SRVRMGR_OVERLAPPEDpack)
typedef CTypedPtrList<CPtrList, SRVRMGR_OVERLAPPED*> SRVRMGR_OVERLAPPEDPtrList;

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: IOCP again Pin
csrss6-Jul-11 11:11
csrss6-Jul-11 11:11 
QuestionThe code, in short Pin
csrss6-Jul-11 11:58
csrss6-Jul-11 11:58 
AnswerRe: The code, in short Pin
Mark Salsbery6-Jul-11 13:21
Mark Salsbery6-Jul-11 13:21 
GeneralRe: The code, in short Pin
csrss6-Jul-11 14:53
csrss6-Jul-11 14:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.