Sockets and Active X
-
Hi All, I am writing a COM Dll in ATL to integrate 2 applications that talk to each other using sockets. I am new to sockets and have a few queries -- I am using the MFC based CSockets to read and write. When the API, "Accept" is used, a new socket is created with the same properties which can be used to write to a target socket. Can we use the same socket for reading data that is being written on my socket ? I would like to spawn different thread for reading and writing. Is it advisable to use the same socket ? Cheers Raja
-
Hi All, I am writing a COM Dll in ATL to integrate 2 applications that talk to each other using sockets. I am new to sockets and have a few queries -- I am using the MFC based CSockets to read and write. When the API, "Accept" is used, a new socket is created with the same properties which can be used to write to a target socket. Can we use the same socket for reading data that is being written on my socket ? I would like to spawn different thread for reading and writing. Is it advisable to use the same socket ? Cheers Raja
In your first question you have asked, as I understand that you want to read/write operations on a same socket. it is absolutely valid. When a client connect to the server. The server accepts it and a new socket is created that represent the client socket on the server. In tern when you write something on it in the server, is send to the client for the reading. And when client write something, that is sent to the server and the server can read that content on the same socket that is representing the client. According to the second question, you are using the CSocket class of MFC. The CSocket provides the various notifications on the socket like something is received or sent on the socket. These notifications Functions are inherited from its base class CAsyncSocket. And you can override these functions to get the processing done of these notifications. You don't have to you the thread manually in your application for that processing. The MFC Framework already implements it. But if the SDK/Win32 API programming is the choice than you have to manually implement all this functionality. You can find an example app based on CSocket implementation in MSDN at the below link. Hope it would help you. Jitendra
-
In your first question you have asked, as I understand that you want to read/write operations on a same socket. it is absolutely valid. When a client connect to the server. The server accepts it and a new socket is created that represent the client socket on the server. In tern when you write something on it in the server, is send to the client for the reading. And when client write something, that is sent to the server and the server can read that content on the same socket that is representing the client. According to the second question, you are using the CSocket class of MFC. The CSocket provides the various notifications on the socket like something is received or sent on the socket. These notifications Functions are inherited from its base class CAsyncSocket. And you can override these functions to get the processing done of these notifications. You don't have to you the thread manually in your application for that processing. The MFC Framework already implements it. But if the SDK/Win32 API programming is the choice than you have to manually implement all this functionality. You can find an example app based on CSocket implementation in MSDN at the below link. Hope it would help you. Jitendra
Hi Jitendra Thanks so much for clarifying my qn. Wanted to reply to you immediately but could not login to this site :-(( I have realised that when I use a COM dll loaded into my App and wait for Data to receive on my socket (though it is multithreaded, I am using this from VB script of my app), my app hangs until data is recieved. I am now trying to use the Async Method. Could you please help me in this regard? I have generated a COM dll using the ATL COM APP wizard. I inserted a Full control that actually exposes interfaces. I have then defined my own Class, say MySocket derived publicly from AsyncSocket. I now want to use this dll to get notification when there is data to be read, asynchronously. In my interface implementation, I created an instance of MySocket. How do I get notified of the event? Can you email me ur id, so I could send my code to you for better understanding? My email id is shekar_raja@indiatimes.com This is very critical to me, please take time for this. Thanks heaps in advance.... :(( Cheers Raja