Click here to Skip to main content
15,886,519 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: The code, in short Pin
Mark Salsbery6-Jul-11 15:22
Mark Salsbery6-Jul-11 15:22 
QuestionDynamic Tree Pin
john56326-Jul-11 1:28
john56326-Jul-11 1:28 
AnswerRe: Dynamic Tree Pin
Emilio Garavaglia6-Jul-11 2:19
Emilio Garavaglia6-Jul-11 2:19 
AnswerRe: Dynamic Tree Pin
Niklas L6-Jul-11 4:47
Niklas L6-Jul-11 4:47 
QuestionHow to retrieve Icon/Bitmap/HBITMAP information from CMenu? [modified] Pin
nate316-Jul-11 0:30
nate316-Jul-11 0:30 
AnswerRe: How to retrieve Icon/Bitmap/HBITMAP information from CMenu? Pin
Richard MacCutchan6-Jul-11 0:37
mveRichard MacCutchan6-Jul-11 0:37 
GeneralRe: How to retrieve Icon/Bitmap/HBITMAP information from CMenu? Pin
nate316-Jul-11 15:52
nate316-Jul-11 15:52 
QuestionRe: How to retrieve Icon/Bitmap/HBITMAP information from CMenu? Pin
David Crow6-Jul-11 3:52
David Crow6-Jul-11 3:52 
AnswerRe: How to retrieve Icon/Bitmap/HBITMAP information from CMenu? Pin
nate316-Jul-11 15:53
nate316-Jul-11 15:53 
GeneralRe: How to retrieve Icon/Bitmap/HBITMAP information from CMenu? Pin
David Crow6-Jul-11 16:55
David Crow6-Jul-11 16:55 
QuestionAt CADORecordset.Close() Application get crashed. Pin
Amrit Agr5-Jul-11 23:16
Amrit Agr5-Jul-11 23:16 
AnswerRe: At CADORecordset.Close() Application get crashed. Pin
Niklas L6-Jul-11 0:04
Niklas L6-Jul-11 0:04 
GeneralRe: At CADORecordset.Close() Application get crashed. Pin
Amrit Agr6-Jul-11 0:19
Amrit Agr6-Jul-11 0:19 

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.