Solved

WINSOCK in Windows NT Service

Posted on 1997-04-29
5
223 Views
Last Modified: 2013-11-20
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
Comment
Question by:dipesh042997
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:mbhakta
Comment Utility
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
 

Author Comment

by:dipesh042997
Comment Utility
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
 
LVL 4

Accepted Solution

by:
mbhakta earned 100 total points
Comment Utility
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
 

Author Comment

by:dipesh042997
Comment Utility
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
 
LVL 4

Expert Comment

by:mbhakta
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now