|
MFC Sockets are worthless for anything I (and lots of other people) would consder "real use". The problem is that they are still based on the Windows 3.1 sockets design, in that they need to have access to a message handler and etc.
What you're experiancing is probably message stavaration between the socket handlers and the windows handlers - you've got one socket loading down the handler, and none of the other ones can efecitivly get into it. For light use, MFC sockets can work on - for example, look at the Microsoft MSDN exampe "Chatsvr" which is a trivial messaging app using CSockets.
For more robust sockets, I would look into some of the other things here on CodeProject, in the Networking code section. You should also consider using threads to handle socket actions, so that one socket will not load down the system. This is the method I've used in a high-end 1000+ client server - one thread for each client SOCKET handle (no MFC in it).
WarFTP is open sourced I think, and is a Windows app, you might want to give that a look-see.
That's my $0.02
"Perhaps the truth is less interesting than the facts?" -- Amy Weiss, RIAA's Senior Vice President of Communications. It's the new math! 421 == 156 !
|
|
|
|
|
I know MFC sockets are not ideal. But they work well for me, with the exception of this one problem. Otherwise, 30-35 clients even on Win98 and server is absolutely ok...
Yes, I use separate thread for each fike transfer, that's why I can't understand this behaviour...
Is it better to use CSocket or CAsyncSocket ?
Standa.
|
|
|
|
|
s_k wrote:
Server gives no response and the machine where the server is running is totally frozen up. With one exception - file transfer that I've started before, is going on well...When I kill the connection from client, server is ok again (as well as the whole OS).
Sounds pretty odd. I think you need to give details about your socket use.
Do you use CAsnyncSocket (not CSocket)? Do you run sockets asynchronously in one thread context? Check which part is locking up your server, is it really socket core (winsock <-> application messages) or your GUI (application <-> GUI messages)?
|
|
|
|
|
I use my own class derived from CSocket, is it better to use CAsyncSocket ? I start separate working thread for each transfer, so I can't understand why one socket blocks whole OS...
|
|
|
|
|
s_k wrote:
I use my own class derived from CSocket, is it better to use CAsyncSocket ?
I would use CAsyncSocket or something else (but NOT CSocket).
s_k wrote:
I start separate working thread for each transfer, so I can't understand why one socket blocks whole OS...
There are different socket concepts, the possible alternatives are:
a) blocking servers (handling only one request at a time, then wait again blocking)
b) threaded servers (handling simultaneous requests, one thread for every new socket).
c) asynchronous server (handling simultaneous requests, one server thread will handle all sockets - CAsyncSocket will cover this)
The server model always depends on application requirements.
|
|
|
|
|
But when I have the second case (threaded server) and start separate thread for each transfer, it is better to use CSocket, isn't it ?
|
|
|
|
|
s_k wrote:
But when I have the second case (threaded server) and start separate thread for each transfer, it is better to use CSocket, isn't it ?
Are you sure you want this? Multiple threads means using IPC or mutex or even more logic to avoid deadlocks or destroying your shared data. CSocket + multiple threads for incoming sockets is the worst of all combinations/possibilities IMHO.
|
|
|
|
|
But it works perfectly on all platforms, under extreme utilization...This problem only appears on very weak machines (32MB RAM) and only on Win95/98...
|
|
|
|
|
s_k wrote:
But...
you opened the can of worms, good luck with it!
|
|
|
|
|
I'm trying to move my code that compiles and links fine on VC6 to VC++ .NET. When I try to link a DLL that uses another custom DLL, I get a bunch of LNK2005 linker errors related to a new CStringT<> class, like:
"public: __thiscall ATL::CStringT > >::CStringT > >(char const *)" (??0?$CStringT@DV?$StrTraitMFC@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@QAE@PBD@Z)already defined in CFGCoreUI.obj
where LeadHppD.dll is used by the other DLL containing the CFGCoreUI module. I have experimented with project options, but it has got me nowhere as yet.
Merry XMas to everyone here,
Bartosz Bien
|
|
|
|
|
|
Hello,
I've used WS_EX_LEFTSCROLLBAR and WS_EX_RIGHT and WS_EX_RTLREADING extended styles to make right aligned combo box and a left scrollbar in left !
It works fine on NT (Win2000 or WinXP) systems, But it doesn't work on Win98 Arabic
What's wrong ?
How can i fix it ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi dear,
I'm looking for an article or sample, demonstrates using Office xp(2000) Chart in a VC++ or C# project.
Thank you in advance.
|
|
|
|
|
Hi there,
I have a question for understanding the MFC message routing mechanism. Can I describe the purpose of PreTranslateMessage() as following?
"hey window, I have a message. Do you want to handle it or prevent others to handle it?" - "Hm I think about it" - "hey and window, you might not get it via your normal message handlers if you are not designed to get it, catch it now if you need."
Notes: I found out that sending a message directly to a window does not invoke PreTranslateMessage(). Also in some cases message handler seams not to be called (e.g. a CDialog wouldn't normaly get keyboard messages in OnKeyDown() ), strange.
So, I put my stuff into normal MFC message handler and sometimes catch & forward some messages from PreTranslateMessage() . Is that a good idea?
Thx for a short feedback, Moak
|
|
|
|
|
You are right. It's better to use normal message handlers. PreTranslateMessage is used in special cases when standard message handler doesn't work - for example, to handle all keyboard messages in dialog.
|
|
|
|
|
I create a regular dll and implement certain function in it. Then i create a sample program that uses that function from respective dll. But the problem is that i need to distribute dll with my exe otherwise program not works.
Is it possible that i statically link my dll with program in similar manner we statically link MFC dlls. Condition is that I only have dll and lib but not source code.
|
|
|
|
|
Shah Shehpori wrote:
Is it possible that i statically link my dll with program
No, because DLLs don't work that way. Redo your project as a static library, which will build a LIB file. You can link the LIB into your EXE.
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
One more thing, suppose i am calling a function residing in a dll, will it make any speed/performance difference as compared to calling the same function present inside the exe ?
|
|
|
|
|
Shah Shehpori wrote:
ill it make any speed/performance difference as compared to calling the same function present inside the exe?
The call to a static LIB might be minutely faster, because it doesn't have to go through an import table jump instruction, although it's nothing a person would notice.
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
hi,
1>how to remove keys.
2>how to add sub keys and remove them
3>how to access the subkeys
thanx if even read
Brad
|
|
|
|
|
Try here[^].
Software Zen: delete this;
|
|
|
|
|
hi,
I am drawing these engineering related drawings that need a lot of pre calculation for neat display before actually being rendered to the user.Every time.Zooming included.I (naturally) used CreateCompatibleDC() function,drew onto that, calculated stuff and continued from there.
The problem arises while scrolling.I set the scrolling sizes according to the bounds of the drawing plus spaces.The bound is calculated as said earlier.When i scroll, things get eaten away.However, moving the drawing slowly using the arrow keys works fine.
Why is this happening?Help.Drawing is the soul and life and ... of my sw
Kofi Ntini
|
|
|
|
|
It sounds like the scrolling is not invalidating the correct part of the window.
Software Zen: delete this;
|
|
|
|
|
Sir, I want to develop OutSmtp type application. For that it is necessary to find out MX Record for a particular domain. For example if the To: address is abc@xyz.com, first of all I have to find out the mail server of xyz.com.
How can I get the MX Record of a domain? Please help me....
C.R.Naik
|
|
|
|
|
You should get it from the DNS.
NSLookup might help.
|
|
|
|