|
Made an interesting discovery!! Changed the code to look like:
pOverlapped->hEvent = WSACreateEvent();
int nBytesRecv = WSARecvFrom(pClientContext->GetSocket(), pWSABUF, 1, &dwBytesTransferred,
&dwFlags, (sockaddr*)&from, &nFromLen, pOverlapped, NULL);
WaitForSingleObject(pOverlapped->hEvent, INFINITE);
Now, when I send it "0\r\n" ONE time, it blocks on the WaitForSingleObject forever. If I send it a SECOND "0\r\n", it now passes the WaitForSingleObject() and has the 0\r\n in the buffer! what the heck??? Its like one behind or something.
|
|
|
|
|
Hmm.. another discovery . It is not one packet behind. It is just not getting the first packet for some reason. If I send it "0\r\n", "1\r\n", "2\r\n", 1 and 2 work, but 0 does not.
|
|
|
|
|
ARGH!! found the problem. I had a fundamental misunderstanding of the logic flow when using I/O completion ports. The TCP side was working, but not in the way I thought it was . The UDP side is also working now.
Basically with I/O completion ports, you ALWAYS get a IO pending on sends & recvs. The GetQueuedCompletionStatus() function operates like a wait. On the TCP side, I created a new CClientContext for each connection which is correct and thus the WSABUF was passed around correctly. On the UDP side, I can't have the shared buffer obviously because it all comes from multiple clients at the same time. So I need to derive a new struct from OVERLAPPED and add the shared members there for UDP and pass that around.
Basically once you get the GetQueuedCompletionStatus() notification, the buffer is already full (assuming you still have access to it -- in my current design, I didn't). Then you call wsarecvfrom AGAIN and it'll start a new overlapped call until new data is available, then GetQueuedCompletionStatus() will return again and so on.
Thanks again for your help.
|
|
|
|
|
Fine that you find the problem.
SledgeHammer01 wrote: So I need to derive a new struct from OVERLAPPED and add the shared members there for UDP and pass that around.
I expected something like that.
|
|
|
|
|
I have ported a DLL project from VC6 -> VS2010. It gives the following link error.
LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12
How to resolve this error?
|
|
|
|
|
|
it compiles in vc6. Only in vs2010 link error.
|
|
|
|
|
so, check your vs2010 settings. confirm that it's linking with the MS runtimes.
|
|
|
|
|
yes. It seems like some MS library links by default in vc6 but not in vs2010. Will have investigate further. Thanks for your info.
|
|
|
|
|
KASR1 wrote: How to resolve this error?
See here. It almost sounds like a Unicode issue. Do you have UNICODE and/or _UNICODE defined?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
modified 30-Jan-12 12:44pm.
|
|
|
|
|
i was able to compile the project in vc6, it gives error only in VS2010(after porting). Something related to environment. I couldnot get it
|
|
|
|
|
It wasn't Unicode, was it? Well I'm betting it is now. Sounds wrong entry point for a Unicode app.
Steve
|
|
|
|
|
Hello All,
I have a mfc application. I have an ActiveX control qualitycontrol.ocx.I want to load a dialog of that ActiveX control and call it's methods on button click of my mfc application.
Please help me how to do that?
|
|
|
|
|
Right click on a dialog and select Insert ActiveX Control .
|
|
|
|
|
First of all thank you for replying. But when I right -click on the dialog and 'insert activeX control' it shows windows activeX control but I want to include my own activeX control "qualityControl.ocx" and call a memeber function defined in that control.
Please help me how to do that.
Adity
|
|
|
|
|
Is your control visible in the Insert ActiveX Control Listbox?
if not then you have not registered the activeX control. You need to put that control in Windows->System32 and open it using Regsvr32.exe. which is available in the same folder. And now you need to try again right clicking the mouse and selecting the "Insert ActiveX Control"
Once it is available select the control and then you can create a member variable for that and call the necessary member functions through that member variable.
Every new day is another chance to change your life.
|
|
|
|
|
Hi,
yes I have registered the control and added header file and .cpp file of that control using Add-> class->MFC from ActiveX into my project. I created a member variable of that class by the following code on button click of my application
CQualityCheck chkdlg;
chkdlg.callSample("");
but while running it is showing error in the following code winocc.cpp file:
void AFX_CDECL CWnd::InvokeHelper(DISPID dwDispID, WORD wFlags, VARTYPE vtRet,
void* pvRet, const BYTE* pbParamInfo, ...)
{
ASSERT(m_pCtrlSite != NULL); // not an OLE control (not yet, at least)
if (m_pCtrlSite == NULL)
return;
va_list argList;
va_start(argList, pbParamInfo);
m_pCtrlSite->InvokeHelperV(dwDispID, wFlags, vtRet, pvRet, pbParamInfo,
argList);
va_end(argList);
}
Please help how to resolve this?
Adity
|
|
|
|
|
The list that you see is not Windows ActiveX Controls.
They are all the registered ActiveX controls.
Like Chandrasekharan said, you need to register the ActiveX control using regsvr32.exe
However, you do not need to place it in the system32 folder.
You can place it in any folder.
|
|
|
|
|
«_Superman_» wrote: However, you do not need to place it in the system32 folder.
You can place it in any folder
Thanks for this information. I normally put in in System32 folder and register it.
Every new day is another chance to change your life.
|
|
|
|
|
Hi,
yes I have registered the control and added header file and .cpp file of that control using Add-> class->MFC from ActiveX into my project. I created a member variable of that class by the following code on button click of my application
CQualityCheck chkdlg;
chkdlg.callSample("");
but while running it is showing error in the following code winocc.cpp file:
void AFX_CDECL CWnd::InvokeHelper(DISPID dwDispID, WORD wFlags, VARTYPE vtRet,
void* pvRet, const BYTE* pbParamInfo, ...)
{
ASSERT(m_pCtrlSite != NULL); // not an OLE control (not yet, at least)
if (m_pCtrlSite == NULL)
return;
va_list argList;
va_start(argList, pbParamInfo);
m_pCtrlSite->InvokeHelperV(dwDispID, wFlags, vtRet, pvRet, pbParamInfo,
argList);
va_end(argList);
}
Please help how to resolve this?
Adity
|
|
|
|
|
Hi, Im having one VB executable file named as VSCModule.exe
I want to use this in MFC to use the functions in that executable.
Previously ,it has used in VB Macros.
Just they add referennces , Tool->References and select VSCModule.exe.
VBA coding :
Dim vsc As New VSCmodule.vsc
vsc.getVar("PL", "PVC101", "PV").Value 'getVar is function belongs to VSCModule
Just i want to know.Can i use this exe in MFC? If it is so How can i use that?
Im using VS2008 version.
I add reference in VC++ in the same way, its get added in References Column as
Interop.VSCModule.1.1
I dont know how to proceed after this?
Pls kindly help me.
Anu
|
|
|
|
|
You can execute any EXE from MFC using the CreateProcess API.
|
|
|
|
|
Anu_Bala wrote: Can i use this exe in MFC
If I understand you correctly, you want to know if you can call functions inside the VB exe from your MFC program.
No you cannot do that. If those fucntions were in a DLL you could but not an exe. You can run the exe and get a result from the VB exe if that will suit your purpose.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
Hi,
I have two questions
First
I have CRichEditCtrl inside a CDialog My first question is can a CRichEditCtrl or for that matter any control accept messages or do all control that are part of Dialog have to have thier messages first go to the CDialog and then have The CDialog process the control('s) messages that live within it
Second if a control can process it own messages is all that is need is have
a DECLARE_MESSAGE_MAP() in the control class defination
and then a BEGIN_MESSAGE_MAP to process the messages for the control
Thanks in advance
|
|
|
|
|