Click here to Skip to main content
16,007,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: winsock packet delimiter separation Pin
Tim Smith22-Feb-02 8:18
Tim Smith22-Feb-02 8:18 
Generalopening a dialog box Pin
Rajveer22-Feb-02 7:37
Rajveer22-Feb-02 7:37 
GeneralRe: opening a dialog box Pin
Sonu Kapoor22-Feb-02 7:51
Sonu Kapoor22-Feb-02 7:51 
GeneralRe: opening a dialog box Pin
Paul M Watt22-Feb-02 8:00
mentorPaul M Watt22-Feb-02 8:00 
GeneralRe: opening a dialog box Pin
Tili2-Dec-02 22:03
Tili2-Dec-02 22:03 
GeneralRe: opening a dialog box Pin
Jon Hulatt22-Feb-02 8:06
Jon Hulatt22-Feb-02 8:06 
GeneralRe: opening a dialog box Pin
mr200322-Feb-02 11:48
mr200322-Feb-02 11:48 
GeneralThread Problems Pin
Jon Hulatt22-Feb-02 7:37
Jon Hulatt22-Feb-02 7:37 
Hi,

Need more help.

I have a single instance of a CAsyncSocket derived class, which is acting as a listening daemon.

When i accept a new connection, I create a new instance of a new object, which is again a CAsyncSocket derived class. This new object is tuned to handle the SMTP conversation itself.

// create a new connection object for the mail
	CMailConnection *p_MailConn = new CMailConnection;

	SOCKADDR_IN pSockAddr;
	int nSockAddrLen=sizeof(pSockAddr);
	
	if (Accept((*p_MailConn),(sockaddr *) &pSockAddr,&nSockAddrLen) == 0)


Now I want to enforce a limit on the number of concurrent connections. I can see two ways of doing this... One is messy and involves manually keeping a count of connections. The other, better way (IMHO) is to use semaphores. This way I can make my OnAccept thread wait for a free connection using the semaphore on WaitForSingleObject().

However, for this to work, I need to get each instance of my CMailConnection object running in it's own thread. I've used worker threads before, ie. calling a function within AfxBeginThread() to do some heavy processing. But I don't know how to start a thread in this case. Can't see that I can use the regular worker threads model: MSDN says that the thread is killed when the pfnThreadProc returns.

Evidently, there is some internal MFC trickery inside of CAsyncSocket that handles the event functions like OnReceive() etc. Dunno where this code is or if it's relevant.

Help!

Sorry to dissapoint you all with my lack of a witty or poignant signature.
GeneralRe: Thread Problems Pin
Paul M Watt23-Feb-02 16:10
mentorPaul M Watt23-Feb-02 16:10 
GeneralRe: Thread Problems Pin
Jon Hulatt24-Feb-02 21:56
Jon Hulatt24-Feb-02 21:56 
GeneralLoading bitmaps Pin
22-Feb-02 6:49
suss22-Feb-02 6:49 
GeneralRe: Loading bitmaps Pin
Not Active22-Feb-02 7:11
mentorNot Active22-Feb-02 7:11 
GeneralRe: Loading bitmaps Pin
Paul M Watt22-Feb-02 7:15
mentorPaul M Watt22-Feb-02 7:15 
GeneralBroadcasting the command Pin
yellowine22-Feb-02 6:23
yellowine22-Feb-02 6:23 
GeneralRe: Broadcasting the command Pin
Tim Smith22-Feb-02 6:30
Tim Smith22-Feb-02 6:30 
GeneralRe: Broadcasting the command: Problem with UpdateAllViews() Pin
yellowine22-Feb-02 6:34
yellowine22-Feb-02 6:34 
GeneralRe: Broadcasting the command: Problem with UpdateAllViews() Pin
Tim Smith22-Feb-02 6:46
Tim Smith22-Feb-02 6:46 
GeneralRe: Broadcasting the command: Problem with UpdateAllViews() Pin
Nish Nishant22-Feb-02 9:18
sitebuilderNish Nishant22-Feb-02 9:18 
GeneralRe: Broadcasting the command: Problem with UpdateAllViews() Pin
yellowine22-Feb-02 10:35
yellowine22-Feb-02 10:35 
GeneralRe: Broadcasting the command: Problem with UpdateAllViews() Pin
pba_22-Feb-02 10:40
pba_22-Feb-02 10:40 
GeneralRe: Broadcasting the command: Problem with UpdateAllViews() Pin
yellowine22-Feb-02 10:42
yellowine22-Feb-02 10:42 
GeneralRe: Broadcasting the command: Problem with UpdateAllViews() Pin
pba_22-Feb-02 12:04
pba_22-Feb-02 12:04 
GeneralRe: Broadcasting the command Pin
22-Feb-02 7:00
suss22-Feb-02 7:00 
GeneralRe: Broadcasting the command Pin
yellowine22-Feb-02 10:36
yellowine22-Feb-02 10:36 
GeneralDeallocating Tree Control Data Pin
Aaron Schaefer22-Feb-02 6:17
Aaron Schaefer22-Feb-02 6:17 

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.