Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Use Sockets in a DLL

Use Sockets in a DLL

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tobeymag
    wrote on last edited by
    #1

    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.

    X 1 Reply Last reply
    0
    • T tobeymag

      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.

      X Offline
      X Offline
      xxrl
      wrote on last edited by
      #2

      Show your code section,please You are the best!Me too!

      T 1 Reply Last reply
      0
      • X xxrl

        Show your code section,please You are the best!Me too!

        T Offline
        T Offline
        tobeymag
        wrote on last edited by
        #3

        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

        X 1 Reply Last reply
        0
        • T tobeymag

          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

          X Offline
          X Offline
          xxrl
          wrote on last edited by
          #4

          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!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups