Sockets fail in NT Services
-
I am writing a service for windows NT. The service itself works fine, but it needs to bind to a socket. The problem is CSocket::Create(port) fails every time. Does anyone know what is going on? Thanks ever so much! -Jason
-
I am writing a service for windows NT. The service itself works fine, but it needs to bind to a socket. The problem is CSocket::Create(port) fails every time. Does anyone know what is going on? Thanks ever so much! -Jason
I'm not a MFC expert (never uses it), but AFAIK CSocket doesn't work with services... You should use plain socket (all the WSA* functions) instead of the MFC wrappers... - Anders Money talks, but all mine ever says is "Goodbye!"
-
I am writing a service for windows NT. The service itself works fine, but it needs to bind to a socket. The problem is CSocket::Create(port) fails every time. Does anyone know what is going on? Thanks ever so much! -Jason
I've experience that some security accounts under which services run can make them fail when accessing network resources, e.g., LocalSystemAccount. Try running the service with Administrator to see if the problem is security related. BTW, what is the value of GetLastError() ? Furor fit laesa saepius patientia
-
I am writing a service for windows NT. The service itself works fine, but it needs to bind to a socket. The problem is CSocket::Create(port) fails every time. Does anyone know what is going on? Thanks ever so much! -Jason
CSocket does not work well with NT services. Check out PJ Naughters class library, which has a number of classes that are derived from his own CSocket class for use with NT services. http://www.codeproject.com/library/pj.asp I've used them quite a bit to get me out of the same situation. Hope this helps, Giles
-
I am writing a service for windows NT. The service itself works fine, but it needs to bind to a socket. The problem is CSocket::Create(port) fails every time. Does anyone know what is going on? Thanks ever so much! -Jason
Did you call AfxSockInit befofre using CSocket? Also, you may have problem making CSocket work correctly because your service is a console application. If you can make your code work in a regular MFC program (outside an NT service), then this tool by Xiangyang Liu might help you. Good luck.