|
ForNow wrote: don’t think the wait should be in the main thread
If you would implement the Wait... in the main thread then you could wait forever and your main thread could be frozen forever.
BTW, how do you create/obtain the event HANDLEs that you pass in the WaitForMultipleObjects? Are they all correct?
modified 10-May-21 10:37am.
|
|
|
|
|
I am using CreateEvent as it gives me more flexibility i.e auto reset As opposed to WSACreateEvent I then pass everything in a structure pointed to by LPVOID had to build it with no alignment (Zp1) as I was getting slack bytes among members of the structure
thanks
|
|
|
|
|
Could you post some code snippets describing what you do?
|
|
|
|
|
sure be glad to in fact I appreciate it Am at work now (I work as a z/os Mainframe assemnbler programmer ) this has given me a chance to enhance my skills its 10:50 am here EST get off of work 5:00 - 5;30 will do it then thanks for your help
|
|
|
|
|
ForNow wrote: I pass all the info (HWND windows
The MFC framework does not always give you the *real* HWND to a window. As strange as this might sound, the MFC framework maintains two object maps. The 'real objects' and an internal 'temporary handle map'. MFC will sometimes give you a temporary CTempWnd instead. If you are passing the window handle of a MFC class then you need to use CWnd::GetSafeHwnd[^]. There are some rare occasions where GetSafeHwnd cannot give you the real window handle and will return NULL instead so you should probably check for that too.
Not many people are using MFC these days. You should consider moving on.
I can't think of much else that would cause WaitForMultipleObjects to throw an access violation. The only other thing I can think of... is a corrupt heap. Sounds like you are somehow passing garbage to WaitForMultipleObjects.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks I had some other problems
I got rid of the WaitForMultipleObjects and set all my notifications on one event and extracted the correct one with WSAENumnetwork that worked when you say not many people are using MFC do yo mean they coding Windows C API
I found CAsynsockets to be a pain I couldn’t pass along notification to another window
Thanks
|
|
|
|
|
ForNow wrote: when you say not many people are using MFC do yo mean they coding Windows C API
I found CAsynsockets to be a pain I couldn’t pass along notification to another window
I guess he meant they use C#.
I used CAsyncSocket class successfully since many years (until I have changed the company to work for). I never had any problems with this class to work with both IPv4 and IPv6 sockets in IPC with multiple sockets through intranet and internet.
|
|
|
|
|
C/C++ has pointers which gives me flexibility same with native sockets “WSA” when I tried moving my derived CAsyncSocket object pointer notification from a main window to a dialog I ran into problems. No where in the documentation does it say there has to be HWND associated with your CasyncSockets but you have to
I was using CWinThread for notification it has a message pump but doesn’t have a HWND although there is hWnd member ( I think main windows ) member thanks
|
|
|
|
|
It is very hard to understand what you mean, much more harder is to understand what, how, and what for you have implemented in your project. The reason - you avoid to show your code/pseudocode snippets.
Sorry...
|
|
|
|
|
I’ll do that tonite ( it’s 8:45 est by me ) wanted to fix up my code
Thanks
|
|
|
|
|
Question:
Replace all the vowels of the given input string with a single digit number.
Input:
String of length L and all lower-case letters.
Output:
Input String replaced with the digit.
Program explanation:
Replace all the vowels in the given input string with a single digit number you get after all the below
steps.
Step 1: Get the index of the vowel in the given input.
Step 2: Multiply the index with 100.
Step 3: Sum all the prime numbers between 1 and the resulting number from last step.
Step 4: Add the digits of the number you get from the last step until you get a single digit.
Step 5: Now, Replace the vowel with the digit from the last step.
Input:
hello
Output:
h7ll9
Explanation:
Step 1: First vowel found at index 1.
Step 2: 1 * 100 = 100
Step 3: Sum of prime numbers between 1 and 100 is 1060
Step 4: Sum of each digit until we get single digit:
= 1 + 0 + 6 + 0
= 7
Step 5: Replace e with 7
Output now: h7llo
Step 1: Next vowel found at index 4.
Step 2: 4 * 100 = 400
Step 3: Sum of prime numbers between 1 and 400 is 13887
Step 4: Sum of each digit until we get single digit:
= 1 + 3 + 8 + 8 + 7
= 27
= 2 + 7
= 9
Step 5: Replace o with 9
Final output: h7ll9
Example 2:
Input : replace this
Output. : r7pl9c1 th5s
|
|
|
|
|
|
Step 0: Get input.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hello Team,
I am getting the below error while building my MFC project.
C2065 'IUrlHistoryStg2Ptr': undeclared identifier
I have included the <urlhist.h> header file and it is there under the 'External Dependencies' folder.
Could you please suggest me how I can resolve the issue.
Thanking you,
Saikat Das
Software Programmer
|
|
|
|
|
|
|
And according to the discussion below the article Access Internet Explorer's History in MFC :
Quote: Go to Parentinsert these in IEHistory.h
typedef IUrlHistoryStg2* IUrlHistoryStg2Ptr;
typedef IEnumSTATURL* IEnumSTATURLPtr;
|
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
Member 14968771 wrote: I still cannot use my "old - few years " account. Then post a question at Bugs and Suggestions[^] and the administrators will help you.
|
|
|
|
|
Send me an email (sean@codeproject.com) and I will help get you access to your old account.
Thanks,
Sean Ewington
CodeProject
|
|
|
|
|
The WSARecv winsock api has the ability to do overlapped i/o the second parameter is the number of WSABUFs
The sixth parameter is a overlapped structure, the 5th parameter of the overlapped is one or MORE WSAevents I would be doing a
WSAWaitForMultipleEvents with each event corresponding to a buffer when WSAevent ...n is signaled WSABUF ... n would have data I would then have to put the buffer back together think I got it right
thanks
Forgot one more thing I am doing WSAAsyncSelect to have a receive notification sent to the window when that message is sent I am assuming i/o is Imminent should I create a thread to do the
WSAWaitForMultipleEvents or since I got a notification the receive is about to happen doing it in the window under the main thread is ok
thanks
modified 25-Apr-21 23:30pm.
|
|
|
|
|
hI
I create four CAsynSocket Classes in four CwinThread classes When I first create them Socket (with notification events) bind ioctl, setsockopt. I follow the CASynSocket::Socket call to sockcore.cpp and
pState-> m_hSocketWindow has a valid Hwnd Value. The context of the creation of sockets in the CwinApp after my main CFrameWnd has been created.
I then start a conversation with the server (connect send and then receive). It is at a point that I would like to give the work over to a modeless dialog. this is where things go wrong. After getting a message
from the server I try to do a detach which goes to
CAsyncSocket::AsyncSelect(long lEvent) however at this point
_AFX_SOCK_THREAD_STATE* pState-> m_hSocketWindow == NULL is NULL
Since I was debugging this in release mode I never got the subsequent assert on this.
First off in the documentation for CAsynSocket there is no mention that i need a Hwnd to process the class when I first did the CAsynSocket::Socket call with the event notification that I wanted to be informed on
I did notice that
pState-> m_hSocketWindow
had a valid window
When I first started using CAsyncSocket I know very little about TCPI/IP or OO
at this point looking at Winscok API it has much more flexability so much so it seem I dont necessary need a valid Hwnd but a kernel object such as that from CreateEvent will do
more so It seems if I want to pass notification to a different windows I just do another call to
WSAAsyncSelect
with a new HWND
Still I am wondering why
pState-> m_hSocketWindow
went to NULL
|
|
|
|
|
|
Thanks talk about fair I don’t think it’s fair for Microsoft to Have us use CAsyncSocket
Just my opinion
|
|
|
|