Use Sockets in a DLL
-
Hi, I am writing a DLL in VC++, which needs to send and receive messsages using sockets. Everything goes until I create the Socket using the Object of the CAsyncSocket derived class. The error message it gives me is this : error2248 : Cannot access public member 'Create' of CAsync Socket I've checked the MSDN Error Code. But all I get is that it needs to keep the same state.:sigh: Please reply as soon as possible.
-
Hi, I am writing a DLL in VC++, which needs to send and receive messsages using sockets. Everything goes until I create the Socket using the Object of the CAsyncSocket derived class. The error message it gives me is this : error2248 : Cannot access public member 'Create' of CAsync Socket I've checked the MSDN Error Code. But all I get is that it needs to keep the same state.:sigh: Please reply as soon as possible.
-
That problem has been solved. I was not deriving CAsyncSocket class as public(goofed up). But still I have a problem. I want to use the socket in an Extension Dll, that is used by the SNMP Service. Yes, I am developing an SNMP Agent. I want to use sockets to send/recieve data, for which I need the services of a socket. #include "Connector.h" // The file that comprises of the CAsyncSocket derived class Connector Cn; // Entry Point for the DLL BOOL APIENTRY DllMain(...) .. { WSADATA wsaData; long Events = FD_READ | FD_WRITE | FD_CONNECT | FD_CLOSE | FD_ACCEPT; WSAStartup(MAKEWORD(1,1),&wsaData); AfxSocketInit(); switch(ul_reason_for_call) { case DLL_PROCESS_ATTACH: /* The problem lies here. If I don't use this line tha Agent will send traps correctly. But when I create this socket nothing happens. The Agent does not send traps *1 Cn.Create(128,SOCK_DGRAM,Events,"127.0.0.1"); break; I dont seem to know what is the problem. Please Reply as soon as possible as I am working on a project. Thanks
-
That problem has been solved. I was not deriving CAsyncSocket class as public(goofed up). But still I have a problem. I want to use the socket in an Extension Dll, that is used by the SNMP Service. Yes, I am developing an SNMP Agent. I want to use sockets to send/recieve data, for which I need the services of a socket. #include "Connector.h" // The file that comprises of the CAsyncSocket derived class Connector Cn; // Entry Point for the DLL BOOL APIENTRY DllMain(...) .. { WSADATA wsaData; long Events = FD_READ | FD_WRITE | FD_CONNECT | FD_CLOSE | FD_ACCEPT; WSAStartup(MAKEWORD(1,1),&wsaData); AfxSocketInit(); switch(ul_reason_for_call) { case DLL_PROCESS_ATTACH: /* The problem lies here. If I don't use this line tha Agent will send traps correctly. But when I create this socket nothing happens. The Agent does not send traps *1 Cn.Create(128,SOCK_DGRAM,Events,"127.0.0.1"); break; I dont seem to know what is the problem. Please Reply as soon as possible as I am working on a project. Thanks
You can read follow samples,maybe you can find a solution from them: http://www.codeproject.com/internet/SNMP\_Agent\_DLL\_\_Part1\_.asp http://www.codeproject.com/internet/SNMP\_Agent\_DLL\_\_Part2\_.asp http://www.codeproject.com/internet/mdftpclient1.asp http://www.codeproject.com/internet/LymingtonPGO.asp 1.You can create class object in your services. 2.In your services,you initialize CSocket,maybe it is useful. :laugh::-D You are the best!Me too!