Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

WINSOCK in Windows NT Service

IS there any special requirement to use the MFS socket library inside Windows NT service program ? I tried to use CAsyncSocket class object and I call Create() member function. But My program execution is getting blocked ar Create function. It means I am not able to create Socket. When I use Winsock library functions like socket(), bind() then it works fine. SO I want to know is there any special requirement for MFC Socket library in Windows NT service. ? I am working on Microsoft Visual C++ 4.2 with WIndows NT server 4.0
0
dipesh042997
Asked:
dipesh042997
  • 3
  • 2
1 Solution
 
mbhaktaCommented:
MFC socket API's work for application level. I have tried them out myself but never really liked them. I strongly recommend using winsock or wininet.dll API's directly. They are faster and clear cut. Don't even think of using MFC in a service. Mainly for two reasons :
- Code size - MFC has his own overheads
- Speed - all messages need to go thru the MFC messaging and then to the kernel. Why do it ?

I have designed my own socket classes for my clients, and I recommend you do the same.
0
 
dipesh042997Author Commented:
I got answer regarding performance degradation if we use MFC in WIndows NT Service but I want to know that is there any special requirement for that ?
0
 
mbhaktaCommented:
Try reading the answer once again. The first two lines tell you what happens when you take MFC low-level. The rest of the lines are just suggestions for 'good' low-level programming. This is an advice forum where experts add additional advice free of cost thru their experience. If you think you are smart enough not to take suggestions, then, you are mailing your questions in a wrong place, may be you can sort your problems yourselves.
0
 
dipesh042997Author Commented:
Come on !, My intense was not that. I always wel come suggestions from the experts. I read your answers couple of times. I really appreciate your suggestion but  as per exisiting design and schedule of my project, it may not be possible for me to develop my own class library and that is the reason why I want to use MFC Socket.
0
 
mbhaktaCommented:
Well, you don't need to develop class library for just that. All you need are wrapper functions which call winsock or wininet functions internally. The class will only help you in taking care of global handles, callback functions etc. That is what MFC does for you anyway. But MFC also internally accesses other of its classes which donot behave very well when implemented in a service or a hook. That is the reason you need to put MFC in its place and rely on lower level API's.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now