|
First of all, sorry so long. I'm pulling my hair out on this problem! Check out the short description below and skip if not interested or beyond your level of expertise.
The short: I have intermittent problems communicating using TCP/IP on Windows XP Service Pack 2 with a pKernel (Posix compliant) embedded device. The embedded device is external to the PC and communicates with a PC via ethernet and/or serial port. Ethereal (sniffer) run on my XP SP2 laptop shows connection requests (SYN) are seen by Ethereal, after the embedded device is reset, but not seen by Windows XP. I am strongly leaning towards this being exclusively an XP SP2 problem but have some doubts that it may be my embedded device.
Details:
1. Problem only occurs on Windows XP SP2. I have tested with Win98 and Win2K and everything is fine. Also this problem did not occur with XP Service Pack 1. Win XP service pack 2 includes several network security things (no details) including a time client. My time server is RFC-868 compliant, referred as Time Protocol, server, and uses TCP/IP or UDP port 37. The SP2 time client is not enabled by default and uses a different port so it is not causing the problem. Some of the SP2 changes were available as add-ons to SP1 but I did not try them.
2. If time server app or service is restarted, the embedded device connects to my XP SP2 machine, every time. It is only when the embedded device is reset or powered off/on, that the embedded device cannot connect to the XP SP2 machine. Eventually after multiple resets, a connection occurs. Once a connection is made, I can re-connect endlessly as many times as desired until I reset the embedded device.
3. Problem initially was discovered with a time server module I embedded into my application. It was later discovered the problem also happens with a TFTP server module, I embedded into my application.
4. Problem was confirmed using third party time server application and third party TFTP server application.
5. Saw some Microsoft documentation that said servers should be installed and run as a service on Windows XP so I made a standalone service for the time server, and it works in Win2K flawlessly, but still fails the same way on XP SP2.
6. The embedded device tries to get time from a time server on booting up or reset, then it sets its time, and runs any onboard (flashed) application. The kernel calls a kernel library (inetlib) function, I think called cmd_ntime() to retrieve the time. As a test, I wrote a test application for the embedded device, that called the same function. FAILED. Later, I rewrote another application for the embedded device. This application was a time client (instead of calling the kernel function) that requested time from the XP SP2 machine. FAILED. Both of these test apps looped and requested time every 4 seconds. IMPORTANT: I should say that since it ran every 4 seconds, I was able to verify through debug msgs on the serial port and via Ethereal, that the application program was waiting for the connection to complete. After about a minute and a half, it inevitably connects successfully and from that point on, I can get time every 4 seconds.
7. There are no firewalls running. The problem is repeatable on numerous PCs running XP SP2.
8. ARP and MAC addresses for both the embedded device and the XP SP2 machine seem OK. I verified on the XP SP2 machine that a dynamic table was built that held/had the embedded devices MAC/IP.
When running Ethereal and seeing that a TCP/IP connection is initiated from the embedded device by send a SYN packet, it appears that XP SP2 is not seeing it but the sniffer is. Not knowing networking and driver layers that well, we strongly suspect that one possiblity may be that the SYN connection request is not being passed up the layers correctly.
Freaky Things:
I can actually get it to work, if I don't clean up my sockets i.e. don't do a shutdown() and close() socket. I have tried blocking and non-blocking (currently non-blocking using FD_SET). Documentation says that FD_SET and macros support 64 sockets and can be made to handle more sockets by resizing the structure. HOWEVER, when it does work, there are still problems. Ethereal reports a DUPlicate ACK to the initial SYN e.g. embed dev [SYN], XP SP2 [SYN,ACK].
I actually had a third party time client application which I tested on all operating systems. It also failed with XP SP2. But when I recoded my time server into a service, it now works every single time from the XP SP2 laptop or from another machine.
We have verified the cables, hubs, network adapters, (all networking hardware) are all working fine. The embedded device transmits plenty of UDP data just fine.
HERE'S WHERE I NEED HELP. Is there a sniffer (or does my current one) sniff all OSI layers? If not, does Microsoft have some sort of sniffer or debugger that would perhaps show me the data or TCP/IP connection request being passed up the layers?
Any other suggestions would be greatly appreciated. I have been working on this for over 3 weeks starting multi-threaded spawning threads for each connection request to eventually a test configuration of non-blocking service without threading. I've pulled any code that might hinder isolating this problem. THANK YOU.
-- modified at 22:47 Thursday 2nd February, 2006
|
|
|
|
|
I have a MFC application that has a lot of list view in report mode. I have implemented a CGenericListCtrl (derived from CListCtrl) that contains common functionality used in all those list views. All the list views used in my applicatons are derived from CGenericListCtrl. What I am trying to do is basically impement the sorting functionality based upon the type of the columns. For example some columns could be numeric whereas other could be string or date type. In the CGenericListCtrl I have implemnted a Compare function that apply the sorting algorithm depending upon type of the column. So Let's say I have a class CMYFirstListCtrl that is derived from CGenericListCtrl. In CMYFirstListCtrl at the time of creation of columns I also have an array that contains the type of data stored in each column ( via some enumns). What I am trying to do is that when user click on CMYFirstListCtrl header for sorting, I need to pass the column type enum to Compare method of CGenericListCtrl. Can anyone please help me how can I pass this info from a derived class to its parent though some sort of notification?
|
|
|
|
|
Hi
I am not sure if I have understood your problem!!!
What I think is that you can implement the funtionality for parent class instead of derive class, so that the parent class funtion can directly be called. this may not help you lot...
other method you may use "super" to get parent class methods and variable.
|
|
|
|
|
There is no keyword super in C++. It's available only in Java.
I am not seeing any problem whatsoever using the Sort function of the Base class. Just call the method Sort(...) and pass the parameters. As long as the Sort method is not virtual, you will always end-up in the Base class method.
Alternatively you can think of making Sort(...) method static as long as it is not refering any class memebers and you are passing all the values in the parameter list. You can invoke the method using CGenericListCtrl::Sort(...)
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Thanks for the response guys. Problem is that OnColumnClick is invoked from the dervied class and during that event I am not sure how can I pass this additional variable containing type of the header. Is there any lParam type of thing that I use to fill in this info? Thanks
|
|
|
|
|
I was browsing through the site a few weeks ago, and came a cross a simple http client that would run from a command line in the command prompt. I have tried searching again for it to no avail.. do projects sometimes get taken off of this site? If not, does anyone know which one I am talking about, and maybe provide a link?
|
|
|
|
|
conrad10781 wrote: do projects sometimes get taken off of this site?
Occasionally, authors request that their articles are removed, so yes. Also, sometimes articles are moved between categories.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I'm clueless about using the IHTMLDocument2 interface. How do I use it to load a url or a html document? What about IDispatch Interface, do I need to use it?
|
|
|
|
|
|
Hmm what about the IHTMLDocument2 interface? how do I link the url to this interface?
|
|
|
|
|
|
Hmm what if I want to load the html document saved to disk?
|
|
|
|
|
Try this. It uses ATL. It extracts the text from google and prints it in a message box. I wipped it up pretty quickly so it's not perfect, but it works.
---
// Only needed if you're using an old SDK that hasn't got this. Remove
// if it clashes with your SDK.
MIDL_INTERFACE("3050f613-98b5-11cf-bb82-00aa00bdce0b")
HTMLDocumentEvents2 : public IDispatch
{
};
// Class to wait for the ready state to change to "complete"
// while running a message loop.
class ATL_NO_VTABLE CReadyStateComplete :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatch
{
public:
CReadyStateComplete() : m_spDoc2(NULL)
{
m_hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
}
~CReadyStateComplete()
{
CloseHandle(m_hEvent);
}
void SetDocument(IHTMLDocument2* pDoc2)
{
m_spDoc2 = pDoc2;
}
DECLARE_NO_REGISTRY()
BEGIN_COM_MAP(CReadyStateComplete)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
void Wait()
{
AtlWaitWithMessageLoop(m_hEvent);
}
public:
STDMETHOD(GetTypeInfoCount)(UINT* pctinfo)
{
return E_NOTIMPL;
}
STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
{
return E_NOTIMPL;
}
STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, UINT cNames,
LCID lcid, DISPID* rgdispid)
{
return E_NOTIMPL;
}
STDMETHOD(Invoke)(
/*[in]*/ DISPID dispIdMember,
/*[in]*/ REFIID riid,
/*[in]*/ LCID lcid,
/*[in]*/ WORD wFlags,
/*[in, out]*/ DISPPARAMS * pDispParams,
/*[out]*/ VARIANT * pVarResult,
/*[out]*/ EXCEPINFO * pExcepInfo,
/*[out]*/ UINT * puArgErr)
{
if ( dispIdMember == DISPID_READYSTATECHANGE )
{
CComBSTR State;
if ( SUCCEEDED(m_spDoc2->get_readyState(&State)) )
{
if ( wcscmp(State, L"complete")==0 )
{
SetEvent(m_hEvent);
}
}
return S_OK;
}
return DISP_E_MEMBERNOTFOUND;
}
private:
CComPtr<IHTMLDocument2> m_spDoc2;
HANDLE m_hEvent;
};
void ExtractText()
{
HRESULT hr;
// Get a stream on the URL.
CComPtr<IMoniker> spMk;
hr = CreateURLMoniker(NULL, OLESTR("http://www.google.com/"), &spMk);
if ( FAILED(hr) )
{
return;
}
CComPtr<IBindCtx> spCtx;
hr = CreateBindCtx(0, &spCtx);
if ( FAILED(hr) )
{
return;
}
CComPtr<IStream> spStream;
hr = spMk->BindToStorage(spCtx, 0, IID_IStream, (void**)&spStream);
if ( FAILED(hr) )
{
return;
}
// Create the HTMLDocument object.
CComPtr<IUnknown> spUnk;
hr = spUnk.CoCreateInstance(CLSID_HTMLDocument);
if ( FAILED(hr) )
{
return;
}
CComQIPtr<IPersistStreamInit> spPSI(spUnk);
if ( !spPSI )
{
return;
}
CComQIPtr<IHTMLDocument2> spDoc2(spUnk);
if ( !spDoc2 )
{
return;
}
// Set up our object which watches the ready state of the document.
CComObjectGlobal<CReadyStateComplete> RS;
RS.SetDocument(spDoc2);
DWORD Cookie;
hr = AtlAdvise(spUnk, &RS, __uuidof(HTMLDocumentEvents2), &Cookie);
if ( FAILED(hr) )
{
return;
}
// Load the data from the URL into the object.
hr = spPSI->Load(spStream);
if ( FAILED(hr) )
{
AtlUnadvise(spUnk, __uuidof(HTMLDocumentEvents2), Cookie);
return;
}
// Wait (while running a message pump so MSHTML can work) till ready.
RS.Wait();
AtlUnadvise(spUnk, __uuidof(HTMLDocumentEvents2), Cookie);
// Print out the text in a message box.
CComPtr<IHTMLElement> spBodyElement;
hr = spDoc2->get_body(&spBodyElement);
if ( FAILED(hr) )
{
return;
}
CComBSTR Text;
hr = spBodyElement->get_outerText(&Text);
if ( FAILED(hr) )
{
return;
}
MessageBoxW(NULL, Text, L"Text", MB_OK);
}
Steve
-- modified at 7:41 Friday 3rd February, 2006
Added AtlUnadvise calls without testing......
|
|
|
|
|
Hi,
I am using Visual Studio .Net 2003. I compiled my MFC application in release mode. I then clicked on the executable, and my MFC GUI started. However, when I transfer the executable to other companies, the GUI doesn't start (actually, no response at all) when I click on the executable file. So does anyone why is this?
Thank you very much!!!!!!
|
|
|
|
|
the problem would be related mfc 7.0 dlls or dotnet 1.1 env..
Anderson Sheen (exteide@gmail.com)
The Extension IDE: http://www.exteide.com
|
|
|
|
|
You need to make sure that you send the MFC libraries along with your application. The libraries for the version of MFC in VS2003 are version 7.1.
I'm not sure this is all of your problem, however. Missing libraries usually causes a message box to appear. If you're not getting any response from the application, then there may be an additional problem involved.
Software Zen: delete this;
|
|
|
|
|
Thanks for your help
Now, I ask my friend to open my project and then re-compile, however, he got these 2 error messages:
LNK4098: defaultlib "LIBC" conflicts other libraries, please use /NODEFAULTLIB:Libray
LNK4098: reference to all of 'OLEAUT32.dll' are deleted by /OPT:REF
So what do these two messages mean? How can I fix them?
Thanks a lot
|
|
|
|
|
Hi all,
I am trying to write an application that will allow me to create a new Email account in Outlook Express.
The app has 3 fields that will need to be filled out:
- Display Name
- Username
- Password
Now, the problem that I have is, that the Password value from this field doesn't get written correctly into the Registry.
I am using the following code:
RegSetValueEx(hKey, "POP3 Password2", 0, REG_BINARY,(const BYTE *)&custpass,sizeof(custpass));
Can anyone help me out with this???
Thanks
amano
|
|
|
|
|
Could you show the type of the variable custpass .
Steve
|
|
|
|
|
Hi Steve,
I think that's the type here
CString custpass;
amano
|
|
|
|
|
Ok then. Try this:
<br />
RegSetValueEx(<br />
hKey,<br />
"POP3 Password2",<br />
0,<br />
REG_BINARY,<br />
reinterpret_cast<const BYTE*>(static_cast<LPCTSTR>(custpass))<br />
);<br />
Steve
PS: This is the kind of problem you get when you mix the low level (the RegSetValueEx API) with the high level (CString).
|
|
|
|
|
I just tried to compile it with the new code, but am getting the following error message:
error C2660: 'RegSetValueExA' : function does not take 5 parameters
|
|
|
|
|
Ok, I forgot the size parameter. Try this:
RegSetValueEx(<br />
hKey,<br />
"POP3 Password2",<br />
0,<br />
REG_BINARY,<br />
reinterpret_cast<const BYTE*>(static_cast<LPCTSTR>(custpass)),<br />
(custpass.GetLength()+1)*sizeof(TCHAR)<br />
);
Steve
|
|
|
|
|
Ok...just been able to try this out.
The password is still not being saved to the Registry.
Does it matter where i am trying to write it to?
I am writing it to HKEY_CURRENT_USER\Software\Microsoft\Internet Account Manager\Accounts\
amano
|
|
|
|
|
amano8u wrote: HKEY_CURRENT_USER\Software\Microsoft\Internet Account Manager\Accounts\
HI,
first try by writing some dummy text there!, if you successful in writing that, then try the ansqwer mentioned by Mr. Hewitt
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow cheers, Alok Gupta VC Forum Q&A :- I/ IV
|
|
|
|
|