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. How to create a casyncsocket object in DLL project

How to create a casyncsocket object in DLL project

Scheduled Pinned Locked Moved C / C++ / MFC
c++delphidebugginghelptutorial
8 Posts 3 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.
  • H Offline
    H Offline
    hameduser
    wrote on last edited by
    #1

    I have a MFC Dll project in Visual C6 and use CAsyncSocket class in my project. in wizars forms set "windows socket" checkbox, I get a object from CAsyncsocket and create this, I export function , when use this function in delphi or other programming language I have get one error. I debug my Dll and see occur error in myCasySocket.create() line. void CreateMySocket() { CAsyncSocket myCasySocket; myCasySocket.create(); // << when in line run in DLL occured Error } Thanks, Hamed ral.

    C M 2 Replies Last reply
    0
    • H hameduser

      I have a MFC Dll project in Visual C6 and use CAsyncSocket class in my project. in wizars forms set "windows socket" checkbox, I get a object from CAsyncsocket and create this, I export function , when use this function in delphi or other programming language I have get one error. I debug my Dll and see occur error in myCasySocket.create() line. void CreateMySocket() { CAsyncSocket myCasySocket; myCasySocket.create(); // << when in line run in DLL occured Error } Thanks, Hamed ral.

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      Well, that's nice but more information about the exact error you get would be nice. Is it a runtime error (I suppose so because you said that you try to use the dll in delphi, meaning that you probably compiled it successfully). Also, when you post code, use the pre formating tag (juste above the emoticons).


      Cédric Moonen Software developer
      Charting control [v1.1]

      H 1 Reply Last reply
      0
      • H hameduser

        I have a MFC Dll project in Visual C6 and use CAsyncSocket class in my project. in wizars forms set "windows socket" checkbox, I get a object from CAsyncsocket and create this, I export function , when use this function in delphi or other programming language I have get one error. I debug my Dll and see occur error in myCasySocket.create() line. void CreateMySocket() { CAsyncSocket myCasySocket; myCasySocket.create(); // << when in line run in DLL occured Error } Thanks, Hamed ral.

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        Just guessing, since you haven't indicated what error occurs... The DLL uses MFC so are you initializing MFC properly for a DLL? CAsyncSocket, by default, requires a window (used internally by the class) so there can be problems if MFC is not initialized. Mark

        H 1 Reply Last reply
        0
        • C Cedric Moonen

          Well, that's nice but more information about the exact error you get would be nice. Is it a runtime error (I suppose so because you said that you try to use the dll in delphi, meaning that you probably compiled it successfully). Also, when you post code, use the pre formating tag (juste above the emoticons).


          Cédric Moonen Software developer
          Charting control [v1.1]

          H Offline
          H Offline
          hameduser
          wrote on last edited by
          #4

          Cedric Moonen thanks for your reply. I want develope one DLL in VC6 and create CAsyncSocket in Dll , this DLL is client for my service , DLL must be use all programming environment same as delphi , vb ,... When create one variable from CAsyncSocket in DLL(ConnectToServer function) and call this function (ConnectToServer ) in delphi , get Error CASocket1.create() line. please tell me you and others advance how create one class from CAsyncsocket im my DLL project. Thanks.

          1 Reply Last reply
          0
          • M Mark Salsbery

            Just guessing, since you haven't indicated what error occurs... The DLL uses MFC so are you initializing MFC properly for a DLL? CAsyncSocket, by default, requires a window (used internally by the class) so there can be problems if MFC is not initialized. Mark

            H Offline
            H Offline
            hameduser
            wrote on last edited by
            #5

            I test my DLL in machine write DLL , so that MFC and also visual C are install.

            M 1 Reply Last reply
            0
            • H hameduser

              I test my DLL in machine write DLL , so that MFC and also visual C are install.

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              Right. But, CAsyncSocket is an MFC class, so MFC needs to be initialized on the DLL. Also, you'll need an MFC message loop on a thread somewhere to handle the windows messages. Why not just use the Sockets APIs? CAsyncSocket is just a thin wrapper around them anyway. Mark

              H 1 Reply Last reply
              0
              • M Mark Salsbery

                Right. But, CAsyncSocket is an MFC class, so MFC needs to be initialized on the DLL. Also, you'll need an MFC message loop on a thread somewhere to handle the windows messages. Why not just use the Sockets APIs? CAsyncSocket is just a thin wrapper around them anyway. Mark

                H Offline
                H Offline
                hameduser
                wrote on last edited by
                #7

                Thanks, I didn't work with Socket APIs as yet , let me know if you have any samples or guide me anyway .

                M 1 Reply Last reply
                0
                • H hameduser

                  Thanks, I didn't work with Socket APIs as yet , let me know if you have any samples or guide me anyway .

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #8

                  hameduser wrote:

                  I didn't work with Socket APIs as yet , let me know if you have any samples or guide me anyway .

                  You'd need to understand sockets to use CAsyncSocket as well. Here's the Microsoft documentation: Windows Sockets 2[^] Here's links to many articles: CP Search Articles[^] Mark

                  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