Note the _s on the end and the L prefixing the "%d"
The _s is a good thing as it helps to protect against buffer overflow, but less critical when you are sure that your buffer is big enough. The L prefix on your string is wrong, however, as you are using TCHAR so your buffer could be ASCII or Unicode. You should use the _T() macro around your strings, and the _countof() macro to specify the size thus:
I looked up _countof and discovered the return type is not declared anywhere. Is it an int, unsigned int, size_t, or something else?
The _countof function does not accomodate the null that belongs at the end of a character string. That is important because,...
The various versions of ...printf...( destination, count, source ) that I have tried appear to put a limiting number on the count of characters transferred. However, that limit takes the form of a program crash. Downright nasty! Just as bad as ASSERT.
IMNSHO, these functions should use the count argument to limit the number of characters being transfered rather than crashing the program. Do any of these "safe", or maybe "less dangerous" functions simply limit the number of character moves rather than crashing the app?
I looked up _countof and discovered the return type is not declared anywhere.
If you look closely you will see that it is a macro which invokes the sizeof() operator, so it returns the same type as that.
The various versions of ...printf.
The functions with the _s suffix and the buffer length parameter will avoid the crash by giving you an error return or ASSERT if you attempt to overwrite the buffer, so these functions should always be used for safety. The old "unsafe" versions are part of the base C libraries and remain for backwards compatibility. As you so rightly say, they should not be used any more.
You can trap any ASSERTs that may be raised by adding your own handler as described here[^].
It always pays to read the documentation (including any linked pages) thoroughly. Not that I do so very often.
One of these days I'm going to think of a really clever signature.
dose any one know how to mirror system image list , iam developing RTL application on LTR windows xp , so i want to mirror image before setting listctrl so it will not look upside down ,
her what i did so far and i failed :
I am good through the point where the server calls the Listen() method. There is no client at this time and the code paused for a second or so then continues. My server class has the base class: CAsyncSocket so I presume the OS will eventually send a notification as to when a client connects. What part of the code says to the OS, when the client connects, call function X?
The next operation is to call the Accept( <argument uncertain=""> ) method. Under topic Accepting Connections Wilson suddenly uses m_sConnected as the argument to Accept without explanation. Looking at the downloaded code I think this is an instance of his class MyEchoSocket. But all he does with that class is call methods from the base class CAsyncSocket. Why not just call the CAsyncSocket methods directly?
Edit: The link did not work for me. Try again. I think it is Ok now.
Edit 14 Sep 2012
I think I am beginning to understand.
For question 1:
The programmer must override a set of methods from the base class. These include OnAccept(), OnConnect(), OnReceive(), etc. Windows calls these methods when the event has happened.
For question 2:
When the server code runs, it initiates a listen activity, Windows is listening for a client to connect. When one does, skipping some stuff, an instance of the class written to handle the traffic is created and put into action. That would be an instance of the MyEchoSocket. That class then performs all the sends and receives with the client. Meanwhile, the original server object is fee to go back to listening for another client connect.
No one has posted a reply and this is what I think is supposed to happen. I am still working my code. Please jump in if you have any corrections or comments.
The call to Listen is opening a socket for your server and it basically says "I'm interested in new requests..."
All that is happening at this point is some state has been setup.
The call to accept is actually where the connection is made. The variable m_sConnected is the variable that will receive the new connected socket. Notice how the rest of the calls made if Accept() succeeds are performed on m_sConnected.
In the meantime, m_sListener is still there ready to accept more connections. So if you start another client and then call Accept() with another socket variable, you would have two active client sessions in your application.
I think, AfxGetThread() gets threadId after start of main thread after getting duplicate of handle of thread, because own handle is pseudohandle.
I thing real threadId is from API version of GetCurrentThreadID.
But... same thread would has to have same threadId. It's weirdness
hi every one this is my first post here in fact i'm confused little bit cause i got to finish a project that i haven't started yet i need to capture image with directshow
in fact i haven't understand directshow very well it's questions and pin ... difficult to grasp for the first time .
the second point if i need a window in which i have to put my components should i create it by hand (from scratch by code ) IVideoWindow ?? and what about list & button ??