|
Is this the correct approach to use a prescribed port between two machines, and have Send in one thread and Receive in another thread (since two sockets can't have the same port):
In thread one, create a (TCP connection-oriented) socket and do the Bind (using an IPEndPoint for this local machine on port 8000), Listen, and Accept. Pass the socket returned by the Accept to thread two, and have thread two connect (using an IPEndPoint to the remote port 8000) and Send. After each send, reuse the socket and do another send.
Asynchronously in thread one do Receive's using the socket returned by the Accept. After each buffer is received, queue it (for use by a thread three), and reuse the same socket for another Receive.
The remote sends unsolicited buffers at a fair rate of speed to port 8000, and accepts occassional inbound buffers on its port 8000.
Lee
|
|
|
|
|
Usually, you just want to use the socket you get from Accept for both sending and receiving. You don't have to connect back to the client machine. The client will use the socket it uses to Connect for both sending and receiving as well.
You don't have to worry about "running out" of sockets on port 8000; once you've accepted a connection the port number isn't really used anyway. The only socket that's really bound to 8000 is the Listen socket.
If you are sending and receiving asynchronously, you can use the same socket in a send thread and a receive thread, or you can use the non-blocking functions and run the whole thing from one thread.
|
|
|
|
|
|
hi everybody!
i would like to make two CStatic controls overlap, that is, i would want one CStatic with either the SS_BITMAP or the SS_ICON properties to be placedo over a SS_BITMAP CStatic. i have tried many combinations, but i just can't get it right! can anybody help?
or are there other way's to do it?
thanks,
eugi
www.eugigames.tk
|
|
|
|
|
You will need to ensure the tab order is correct so the "lower" static control draws before the "upper" one. You'll probably also need to give them both the WS_EX_CLIPSIBLINGS style, and maybe the WS_EX_TRANSPARENT style so that they redraw when necessary without stepping on each other.
Shog9
I returned and saw under the sun,
that the race is not to the swift,
nor the battle to the strong...
|
|
|
|
|
thanks! i'll try it and i'll let you know!
www.eugigames.tk
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_0fzo.asp
i read your link...i dont understand how it can help me... MSDN : The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.
i dont even understand what its used for
With Regards
Joseph R. Thomas
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
|
|
|
|
|
Hi,
I wrote a automation program, that uses word object library, to open .doc files and save it as .rtf files. It was not saving the Header/Footer information.
Any Suggestions?
Thanks.
GTS
|
|
|
|
|
I used this code and it retained headers/footers fine:
CString strFileName;
_Application app;
Documents docs;
_Document doc;
COleVariant vtOptional((long) DISP_E_PARAMNOTFOUND, VT_ERROR),
vtFalse((short) FALSE),
vtTrue((short) TRUE),
vtDoc((short) 0),
vtText((short) 2),
vtRtf((short) 6),
vtHtml((short) 8);
if (app.CreateDispatch("Word.Application") == TRUE)
{
docs = app.GetDocuments();
doc = docs.Open(COleVariant(strFileName), vtOptional,
vtOptional, vtOptional,
vtOptional, vtOptional,
vtOptional, vtOptional,
vtOptional, vtOptional,
vtOptional, vtOptional);
strFileName.Replace(".doc", ".rtf");
doc.SaveAs(COleVariant(strFileName),
vtRtf,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional);
docs.Close(vtFalse, vtOptional, vtOptional);
app.Quit(vtOptional, vtOptional, vtOptional);
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi David,
The header/footer appears while open with MS-Word, but the informations are not appear in WordPad.
Is there a compatibility issue? Do you have any idea how to get the header/footer information in wordpad?
Thanks.
GTS
|
|
|
|
|
From what I can tell, Wordpad does not even support headers/footers.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi
I am a C# programmer who needs to generate thumbnails from videos. I have some C++ code that does 99% of what I need, except it's a console application.
All I need to do is re-create it as a Windows Class library but, having never used C++, I am not sure how to do it. I need it to allow me to set a few data items, call the code and return an error message.
Can someone point me to a sample that I can use to do this? I will copy and past my code into it. Or is there someone out there who would like to do it for me for a fee?
Thanks
Eric de la Harpe
|
|
|
|
|
dear all,
how can i use variables with application scope in my mfc dialog based application. where and how do i declare such variables.
regards
rIsHaBh
|
|
|
|
|
It's not a recommended practice to use global variables. What is it that you are trying to do? We can hopefully make some alternative suggestions.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Agreed! but my application is such that renaming my application executable to some other name than the original makes it works differently. so i need a global flag which indiactes the state of the app (based on the name) thru out the application classes. so for this purpose...i cud onmly think of application wide variables.
can u suggest any other way to accomplish this.
Thanx & Regards
rIsHaBh
|
|
|
|
|
It's generally not a good idea to use global variables.
If you must use them, declare them (with extern) in a header file. Include the header file in any .cpp file where you want the global variables to be used.
Put the definition of the global variable (no extern) in one (and only one) of your .cpp files.
|
|
|
|
|
And if you must do it, put them in a namespace!
namespace Global
{
extern bool m_Execute;
};
|
|
|
|
|
Nah, just name them with the g_ prefix. Namespaces can always be bypassed with the using directive. The g_ prefix is clear and simple.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
And can also potentially clash with other globals. It doesn't cost anything to use a namespace and you gain that bit of extra clarity (even though you can work round it) - besides, you can still name them g_ anyway!
|
|
|
|
|
Namespaces can also clash, especially if everyone decides to use Global as the one for global variables.
This goes back to the argument of how to use global variables. I never use them when writing library code. In other words, if I'm writing a DLL that exports code to be used by multiple DLLs/EXEs, I stay away from symbols/names that can potentially clash with other symbols/names in other libraries.
However, I've found global variables extremely convenient for several EXEs where there was only one database connection, one INI file, one set of input parameters, one log file, etc. I just named my variables g_db, g_ini, g_input, and g_log and used those all over the app. It made the code a lot easier to write (vs. Global.m_db all over the place), a lot easier to read (the g_ tells you it's global), and with no chance of name collisions (since only my program had these).
So my point is, everything has a use. You just need to know the when and the how, and even things such as global variables can help us write better code.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
I wonder who's the nutcase that rated your post a 1.
You gave the proper answer, and you get my 5.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
what is the difference between variable definiation and declaration
rIsHaBh
|
|
|
|
|
When you declare something you tell the compiler that a symbol of that name and type will be available at link time.
When you define something, you tell the compiler not only that the variable or function exists, but that it must reserve space for that variable, or create object code for that function, in the current translation unit (.cpp file). When you declare a function or method, you don't include the function body.
You generally put your declarations in header files, which can be shared by many .cpp files that might be part of your program.
You put your definitions in a .cpp file. Generally, each .cpp file together with all the headers it includes make a single translation unit that the compiler converts to a single object file. The object file contains object code for functions defined within the translation unit, and reserves space for static or global variables defined within the translation unit, but it contains only references to functions or variables that were declared but not defined. The linker resolves the references to declared symbols to when it links the object files together with any required libraries to make your final executable.
So in compiling all the parts of your program, the compiler will see the declaration of a symbol several times (once per translation unit that sees the symbol declared) but the definition only once (in the translation unit where the symbol is defined).
|
|
|
|
|
|
Since this is MFC - you don't really need global variables. That is because the MFC framework gives you one automatically - your application class. Just put anything of global scope in your application class (usually CYourProgramApp) and make appropriate accessor functions for it.
You can always get the app by calling AfxGetApp .
Or, as others have said, you can design your code so that it doesn't use globals...
If your nose runs and your feet smell, then you're built upside down.
|
|
|
|
|