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 add Socket support

How to add Socket support

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminhelptutorialquestion
6 Posts 4 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.
  • T Offline
    T Offline
    tina newcoder
    wrote on last edited by
    #1

    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 ...

    P R 2 Replies Last reply
    0
    • T tina newcoder

      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 ...

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      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++

      1 Reply Last reply
      0
      • T tina newcoder

        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 ...

        R Offline
        R Offline
        ramana g
        wrote on last edited by
        #3

        Before using CSocket read this... http://tangentsoft.net/wskfaq/articles/csocket.html[^]

        T 1 Reply Last reply
        0
        • R ramana g

          Before using CSocket read this... http://tangentsoft.net/wskfaq/articles/csocket.html[^]

          T Offline
          T Offline
          tina newcoder
          wrote on last edited by
          #4

          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 ...

          R M 2 Replies Last reply
          0
          • T tina newcoder

            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 ...

            R Offline
            R Offline
            ramana g
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • T tina newcoder

              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 ...

              M Offline
              M Offline
              Moak
              wrote on last edited by
              #6

              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:

              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