Solved

WINSOCK in Windows NT Service

Posted on 1997-04-29
5
225 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
ID: 1301227
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
ID: 1301228
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
ID: 1301229
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
ID: 1301230
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
ID: 1301231
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 84
Pressing cancel button with C# UI Automation 3 51
deburging in oracle form 12 87
Excel file not created as expected 7 46
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

932 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

17 Experts available now in Live!

Get 1:1 Help Now