|
As I'm not aware of the overall purpose of your application it's a little hard to be more specific, but here are a few thoughts.
If you want to send single packets you'll have to use UDP not TCP. There is no way to *guarantee* that TCP/IP packets won't be aggregated, either on your machine, or at some other point along the wire. UDP of course doesn't offer guaranteed delivery so you'll have to engineer that functionality yourself.
Here's a snippet from Warren Young's Winsock Programmers FAQ that you might find helpful:
The whole document is found here
>.3.17 - When should I turn off the Nagle algorithm?
Generally, almost never.
Inexperienced Winsockers usually try disabling the Nagle algorithm when they are trying to impose some kind of packet scheme on a TCP data stream. That is, they want to be able to send, say, two packets, one 40 bytes and the other 60, and have the receiver get a 40-byte packet followed by a separate 60-byte packet. (With the Nagle algorithm enabled, TCP will often coalesce these two packets into a single 100 byte packet.) Unfortunately, this is futile, for the following reasons:
Even if the sender manages to send its packets individually, the receiving TCP/IP stack may still coalesce the received packets into a single packet. This can happen any time the sender can send data faster than the receiver can deal with it.
Winsock Layered Service Providers (LSPs) may coalesce or fragment stream data, especially LSPs that modify the data as it passes.
Turning off the Nagle algorithm in a client program will not affect the way that the server sends packets, and vice versa.
Routers and other intermediaries on the network can fragment packets, and there is no guarantee of "proper" reassembly with stream protocols.
If packet arrives that is larger than the available space in the stack's buffers, it may fragment a packet, queuing up as many bytes as it has buffer space for and discarding the rest. (The remote peer will resend the remaining data later.)
Winsock is not required to give you all the data it has queued on a socket even if your recv() call gave Winsock enough buffer space. It may require several calls to get all the data queued on a socket.
Aside from these problems, disabling the Nagle algorithm almost always causes a program's throughput to degrade. The only time you should disable the algorithm is when some other consideration, such as packet timing, is more important than throughput.
Often, programs that deal with real-time user input will disable the Nagle algorithm to achieve the snappiest possible response, at the expense of network bandwidth. Two examples are X Windows servers and multiplayer network games. In these cases, it is more important that there be as little delay between packets as possible than it is to conserve network bandwidth.
>>
|
|
|
|
|
Interestingly enough, I'm looking at the same problem. I'm working with real-time control systems. The real-time OS is sending data to a monitoring station, which must be updated as soon as possible, and packet sizes can often be as little as 20 bytes. Thankfully data doesn't always change constantly, so network bandwidth isn't the issue, but rather notifying the client as soon as possible is.
|
|
|
|
|
Just to let u know..
There seems to be a problem with SEH raising exceptions in release mode (using VC++ 6 SP4)
In release mode, a divide by zero does not raise any exceptions but it does in debug mode. However, if I uncomment the cout line after the divide (in release mode), an exception would be raised.
If the program was compile with the /EHa option (asynchronous exception), then an exception is always raised.
I didn't do an disassembly but it's probably due to the compiler not generating the divide code since it's not used.
[source]
#include < windows.h >
#include < iostream >
#include < stdexcept >
using namespace std;
void SEH_Translator( unsigned int u, EXCEPTION_POINTERS* pExp )
{
throw exception("SEH exception");
}
void main()
{
try
{
_set_se_translator(SEH_Translator);
int x,y;
x = 9999;
y = 0;
int z = x/y; // cause a divide by zero exception
// cout << z << endl; // uncommenting this throws an exception in release mode
}
catch(...)
{
cout << "Exception caught" << endl;
}
}
[/source]
|
|
|
|
|
As you said, compiler optimization in release mode may have removed the divide-by-zero.
|
|
|
|
|
The reason that an exception doesn't occur in this code in release is because the optimizer will throw all the code away as it does nothing... As soon as you include the cout z has to around so a value can be displayed hence the exception - In a debug build no code is optimized hence you get the behaviour expected.
|
|
|
|
|
I am trying to send a message from a worker thread to a specific class/window in the main dialog. How do I find the HWND of this dialog in order to call PostMessage/SendMessage with the appropriate parameters?
|
|
|
|
|
Your question is similar to the question:
"I am trying to send a letter from my work location to someone downtown. How do I find the address of that person in order to put an address on the letter?"
We cannot help without either guessing or asking you a lot of questions and if you answer all the questions then you will probably have answered your question yourself.
|
|
|
|
|
Ok, whatever the hell that is supposed to mean.
|
|
|
|
|
Roger,
I'm pretty sure that FindWindow will return a valid hwnd for any window currently in the zorder. You need only pass the window title to the function to return the hwnd.
Check the docs or search msdn for FindWindow.
Good luck,
Frank
|
|
|
|
|
The windows I am mostly working with are child windows with no title. I noticed the FindWindow function takes one of two parameters, class name or window name. What do you do if you do not have a title for the window? How do you find the class name?
|
|
|
|
|
You can use Spy++ to retrieve the class name. It should have been installed with VC++ 6. Spy will allow you to select a window to "spy" and then it will give you all the relevant information about that window.
You can also use spy to "spy" on window messages. Nice utility.
Frank
|
|
|
|
|
Thank ya much, never used Spy++, could be a neat adventure.
|
|
|
|
|
When using Spy++ I can find the correct dialog, but all of the dialogs that are open have the same classname, #32770 (that is the classname for ALL dialogs on the application). How do I differentiate between thm when using FindWindow and using the class name parameter?
|
|
|
|
|
Hello,
I think you are on the wrong track with FindWindow.
Why don't you just store the pointers to the ChildWindows in a nice collection class (e.g. in the parent or in your application object) when they are created, and remove them when you destroy them. You can even make them searchable on a particular key (hey, you are the boss, so you decide what the key should be).
Then don't use (p_whatever)->SendMessage(...); // p_whatever is a pointer to a CWnd
but use
HWND theWindow = (p_whatever)->GetSafeHwnd();
if (theWindow != NULL)
{
SendMessage(theWindow, ...);
}
or better use PostMessage.
better still when sending messages to other threads use
PostThreadMessage.
Don't over-complicate things...
|
|
|
|
|
Thanks for the advice, I am currently using PostMessage back to the main window then handling messages from there. Although your advice sounds very interesting about storing them as they are created. It is nice to be the boss and be able to do it how you want isn't it, THANKS!!!
|
|
|
|
|
Notice that in his original question he did not specify that the dialogs he is trying to find were created by him. Since they are, GBO's suggestion is more relevant. This is what happens when questions are not clear.
|
|
|
|
|
Environment: VisualC6.0, no MFC.
How can I assign (eg. F9,F10,F11,F12) hotkeys to select a page on tabcontrol independently? (I'd like to add PgUp-next page and PgDn-prev page, but if anyone can help me, I'll able to do it)
Any help and sourcecode will be appreciated greatly.
---
AkelA
|
|
|
|
|
This seemes easily ehougn done. I'd like to know if there is a class (custom or standard) for accessing Serial ports nearly the same as Socket ports. Once opened and initialized, the reading/writing/closing is nearly the same. The socket has to be able to be a server socket as well, supporting binding and waiting of incoming connections.
Does anyone know of such a class?
|
|
|
|
|
Anyone know how I can find what the path name for "My Documents" is? For the windows and windows/system directory I can use GetWindowsdirectory etc, but what about the "My Documents" directory.
Thanks for any help at all.
Jerry
|
|
|
|
|
isn't it along the lines of
<windowssystemdirectory>\profiles\<username>\My Documents
?
Stephen
|
|
|
|
|
Call SHGetSpecialFolderLocation() and pass it CSIDL_PERSONAL . If you know your target systems will always have the Active Desktop shell, you can use the easier SHGetSpecialFolderPath() API instead.
|
|
|
|
|
|
I have a problem It is About an MSDN sample DBMON.
I will describe the problem irrelative to DBMON and will be
hoping for a generic if not specific answer.
DBMON captures outputdebugstring generated by different processes.
I have implemented it over a network using DCOM. where the ouput
generated by DBMON is seen on client machine through connection points.
It captures OutputDebugString from the processes of that machine in
two scenerios only
1 >>.> If the user on the client machine (where the user is calling DBMON
on the server) is in the local administrator group of the server
machine.
2 >>.> If both user on the server and client machines are same ( I mean
same users not same group ).
There is one another strange thing going on that if the
server process on the server machine itself generates any
outputdebugstring it captures it (only)also irrespective of the
above two conditions. (Does it mean that the remote process
originated by client runs under clients security context .... ?
At least the second situation above have made me think about that )..
---------------- NOW -------------------
I only need a mechanism by which if i can only give the user an option
to connect remotely from one of its local administrator group members
if he is not in first or second situation. I no a password and login
name window will do the trick but donot know how to transfer the access
rights of the currently login client to the one provided in the window
by the client to logon remotely....
If I could just do that................
|
|
|
|
|
I have little problem... i want to create dlg based on HTML, but i encountered problem. In mshtml.dll is function called ShowModelessHTMLDialog, but i cant find any informations concerning it (no, ShowHTMLDialog wont help
Anyone knows how to use it? Or maybe anyone know for any source of html viewer that could be used without restrictions (copyright, etc.)?
|
|
|
|
|
Hi,
Hope this is the right place to post this question.
I'm writing an add-in in the MSVC++ 6.0 Environment.
In the add-in I write to the 'macro' tab of the output window( The window where the build info, search info, etc. is displayed.). The content that is written to this window is in the format of the error messages generated by the VC6 compiler. This helps to go to the source line where the error has occured.
My problem is that I wish to read from the macro tab of this output window the content of the error message (viz. error number, error description etc.) from the add-in code.
Is there any way I can do it? It is easy to write to this window as an API(PrintToOutputWindow) in the IApplication class is provided. didn't find anyway to read from it.
Can anyone help me?
Thanks in advance.
Achyut.
|
|
|
|