How to create a casyncsocket object in DLL project
-
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.
-
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.
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] -
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.
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
-
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]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.
-
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
-
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
-
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
-
Thanks, I didn't work with Socket APIs as yet , let me know if you have any samples or guide me anyway .
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