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. Sockets in Dll

Sockets in Dll

Scheduled Pinned Locked Moved C / C++ / MFC
agentic-aihelpquestion
3 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

    I am developing an SNMP Agent. I want to use sockets to send/recieve data, for which I need the services of a socket. The code works fine, ie compiles correclty. #include "Connector.h" // The file that defines of the CAsyncSocket derived class Connector 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 then the Agent will send traps correctly. But when I create this socket nothing happens. The Agent does not send traps. It kind of just stops working. 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

    K 1 Reply Last reply
    0
    • T tobeymag

      I am developing an SNMP Agent. I want to use sockets to send/recieve data, for which I need the services of a socket. The code works fine, ie compiles correclty. #include "Connector.h" // The file that defines of the CAsyncSocket derived class Connector 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 then the Agent will send traps correctly. But when I create this socket nothing happens. The Agent does not send traps. It kind of just stops working. 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

      K Offline
      K Offline
      kakan
      wrote on last edited by
      #2

      Just a guess, could it happen beacuse you are calling WSAStartup() and AfxSocketInit() for every call of DllMain? You might considder moving those function calls into DLL_PROCESS_ATTACH

      T 1 Reply Last reply
      0
      • K kakan

        Just a guess, could it happen beacuse you are calling WSAStartup() and AfxSocketInit() for every call of DllMain? You might considder moving those function calls into DLL_PROCESS_ATTACH

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

        It is not working. I've probably tried all the combinations. Now, since it is an extension Dll, I am calling AfxInitExtensionModule and AfxTermExtensionModule from DLL_PROCESS_ATTACH and DLL_PROCESS_DETACH respectively. But still the problem persists. ie the dll does not respond when I try to create the socket. Plz check it out, if you could. Thanks

        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