Adding Windows Sockets support to existing MFC application?

Hi experts

For the purpose of adding support of Windows Sockets we check the <Windows Sockets> checkbox in the MFC App wizard step4 of 6.

I have created an MFC SDI application & has completed 80% coding. Currently my application does not supports Windows Sockets as i did not checked the <Windows Sockets> checkbox in the MFC App wizard step4 of 6.

Is it possible to add Windows Sockets support in my MFC SDI application at this stage or wud i need to create a new project with windows sockets support & cut code from old project & paste in new project.

Waiting for suggestions

Regards  
stellarguyAsked:
Who is Participating?
 
Roshan DavisConnect With a Mentor Commented:
windows socket support wizard will only include the header file winsock.h and library wsock32.lib. you can add this after the wizard steps like this

1. Open stdafx.h and add the code..
         #include <afxsock.h>          // MFC socket extensions
2. Open resource.h and add this line after the first line
        #define IDP_SOCKETS_INIT_FAILED            104
3. Open your application class file, in the function initInstance(), put these code as first statements
         if (!AfxSocketInit())
      {
            AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
            return FALSE;
      }
4. Open resource tab, select String table section add
           IDP_SOCKETS_INIT_FAILED, put the string value also

the 2nd and 4th step is optional (only for getting error message if the socket is not initialized properly)
~roshan
0
 
Roshan DavisCommented:
windows socket support wizard will only include the header file winsock.h and library wsock32.lib. you can add this after the wizard steps like this

1. Open stdafx.h and add the code..
         #include <afxsock.h>            // MFC socket extensions
2. Open resource.h and add this line after the first line
0
 
Roshan DavisCommented:
Thankx:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.