How to add Socket support
-
A component of my project is ready, and now i want it to communicate with some administrator(i.e. another component of my project) on the network. But in the beginning, i havn't included the Socket support (while creating new project thro the wizard). How can i add the socket support now and use the CSocket class in my project ... plz help ...
-
A component of my project is ready, and now i want it to communicate with some administrator(i.e. another component of my project) on the network. But in the beginning, i havn't included the Socket support (while creating new project thro the wizard). How can i add the socket support now and use the CSocket class in my project ... plz help ...
You need to add following line only,
#include <afxsock.h>
br mode="hold" />and before using any socket api, make sure you have called following function(Ideally in Initinstance),
AfxSocketInit();
Prasad MS MVP - VC++
-
A component of my project is ready, and now i want it to communicate with some administrator(i.e. another component of my project) on the network. But in the beginning, i havn't included the Socket support (while creating new project thro the wizard). How can i add the socket support now and use the CSocket class in my project ... plz help ...
-
Before using CSocket read this... http://tangentsoft.net/wskfaq/articles/csocket.html[^]
ramana.g wrote:
Before using CSocket read this... http://tangentsoft.net/wskfaq/articles/csocket.html\[^\]
okay.... i read it .... but ways the alternative API ... ? the page give a link to another with a library with its cost ! plz tell me some better solution, i simply want my one component(or program) to communicate with the other (like send string or even file). plz help ...
-
ramana.g wrote:
Before using CSocket read this... http://tangentsoft.net/wskfaq/articles/csocket.html\[^\]
okay.... i read it .... but ways the alternative API ... ? the page give a link to another with a library with its cost ! plz tell me some better solution, i simply want my one component(or program) to communicate with the other (like send string or even file). plz help ...
Use WinSock API (Win32APIs), and write some wrapper classes around SOCKET handle. Use a worker thread to receive data, Parse received data and frame the MESSAGE, which you use to communicate over network. MESSAGE can be something like... struct MESSAGE{ int nMsgId; //To describe data BOOL boolFlag; //Req / Res BYTE *pData; //Actual Data //Some more fields depending on your requirement ... ... }; i think this is enough to start with. You can explore and learn as you progress.
-
ramana.g wrote:
Before using CSocket read this... http://tangentsoft.net/wskfaq/articles/csocket.html\[^\]
okay.... i read it .... but ways the alternative API ... ? the page give a link to another with a library with its cost ! plz tell me some better solution, i simply want my one component(or program) to communicate with the other (like send string or even file). plz help ...
tina- wrote:
okay.... i read it .... but ways the alternative API ... ?
How about CAsyncSocket as an alternative to CSocket? It is better suited for event based applications in my opinion.
My Webchat in Europe :java: