Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

WINSOCK in Windows NT Service

Posted on 1997-04-29
5
Medium Priority
?
238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

721 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