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. Dialog Based Server-Client

Dialog Based Server-Client

Scheduled Pinned Locked Moved C / C++ / MFC
questionsysadmin
9 Posts 7 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.
  • B Offline
    B Offline
    Billar
    wrote on last edited by
    #1

    Dear Friends, I have a source code in which there are 2 socket classes i.e. CSocket & CAsyncSocket for both server and client. Codes on the both classes are almost same i.e. having same message handlers of having same code. I would like to know 1. if server or client program can be written by only one class then what is the use of CAsyncSocket together with CSocket? 2. Although CSocket is derived by CAsyncSocket, but if possible please let me know the benifits and uses of AsyncSocket over CSocket....... Thanking you in advance....... Billar

    J D V P B 5 Replies Last reply
    0
    • B Billar

      Dear Friends, I have a source code in which there are 2 socket classes i.e. CSocket & CAsyncSocket for both server and client. Codes on the both classes are almost same i.e. having same message handlers of having same code. I would like to know 1. if server or client program can be written by only one class then what is the use of CAsyncSocket together with CSocket? 2. Although CSocket is derived by CAsyncSocket, but if possible please let me know the benifits and uses of AsyncSocket over CSocket....... Thanking you in advance....... Billar

      J Offline
      J Offline
      jmkhael
      wrote on last edited by
      #2

      Check here[^] Basically CAsyncSocket is the base class of CSocket. A CSocket object represents a higher level of abstraction of the Windows Sockets API than that of a CAsyncSocket object. CSocket works with classes CSocketFile and CArchive to manage the sending and receiving of data. Papa while (TRUE) Papa.WillLove ( Bebe ) ;

      A 1 Reply Last reply
      0
      • B Billar

        Dear Friends, I have a source code in which there are 2 socket classes i.e. CSocket & CAsyncSocket for both server and client. Codes on the both classes are almost same i.e. having same message handlers of having same code. I would like to know 1. if server or client program can be written by only one class then what is the use of CAsyncSocket together with CSocket? 2. Although CSocket is derived by CAsyncSocket, but if possible please let me know the benifits and uses of AsyncSocket over CSocket....... Thanking you in advance....... Billar

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Billar wrote: 2. Although CSocket is derived by CAsyncSocket, but if possible please let me know the benifits and uses of AsyncSocket over CSocket....... A CSocket object is harder to shut down than a CAsyncSocket object. It is harder to send and receive data, because the thread which is doing the work is tied up. Also a CAsyncSocket object does not require a separate thread. Search the microsoft.public.vc.mfc newsgroup for the pros and cons of both.


        "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

        1 Reply Last reply
        0
        • B Billar

          Dear Friends, I have a source code in which there are 2 socket classes i.e. CSocket & CAsyncSocket for both server and client. Codes on the both classes are almost same i.e. having same message handlers of having same code. I would like to know 1. if server or client program can be written by only one class then what is the use of CAsyncSocket together with CSocket? 2. Although CSocket is derived by CAsyncSocket, but if possible please let me know the benifits and uses of AsyncSocket over CSocket....... Thanking you in advance....... Billar

          V Offline
          V Offline
          valikac
          wrote on last edited by
          #4

          Why are you implementing the client and server using two winsock wrapper classes? Kuphryn

          1 Reply Last reply
          0
          • J jmkhael

            Check here[^] Basically CAsyncSocket is the base class of CSocket. A CSocket object represents a higher level of abstraction of the Windows Sockets API than that of a CAsyncSocket object. CSocket works with classes CSocketFile and CArchive to manage the sending and receiving of data. Papa while (TRUE) Papa.WillLove ( Bebe ) ;

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            But what Billar mean is that there is CAsyncSocket while there is already CSocket-class. So he wants to know why CAsyncSocket is also included? And actualy I want it to know too. By the way, if you want to use CSocketFile and CArchive, do you have to declare them too on a certain way, for using pointers to those type of class? Or isn't that necessary and just typ: CScoketFile *p_mSockFile //for example Thanx!!

            J 1 Reply Last reply
            0
            • A Anonymous

              But what Billar mean is that there is CAsyncSocket while there is already CSocket-class. So he wants to know why CAsyncSocket is also included? And actualy I want it to know too. By the way, if you want to use CSocketFile and CArchive, do you have to declare them too on a certain way, for using pointers to those type of class? Or isn't that necessary and just typ: CScoketFile *p_mSockFile //for example Thanx!!

              J Offline
              J Offline
              jmkhael
              wrote on last edited by
              #6

              The CSocket is a higher level class than the CAsyncSocket. It is easier to manipulate to serialize the data over the network. You dont have to care much about socket notifications, it does all the work for you. But you also lose some flexibility. You can use whatever you need for your application. In order to use CArchive and CSocketFile with an CSocket you just need to create a CSocketFile object (on the heap or on the stack, as you wish)and give it a pointer to your CSocket object. Then when needed you create a CArchive and you map it to a CSocketFile via its constructor and now you are ready to serialize your data on the network by just passing the archive to your serialize function. Papa while (TRUE) Papa.WillLove ( Bebe ) ;

              V 1 Reply Last reply
              0
              • B Billar

                Dear Friends, I have a source code in which there are 2 socket classes i.e. CSocket & CAsyncSocket for both server and client. Codes on the both classes are almost same i.e. having same message handlers of having same code. I would like to know 1. if server or client program can be written by only one class then what is the use of CAsyncSocket together with CSocket? 2. Although CSocket is derived by CAsyncSocket, but if possible please let me know the benifits and uses of AsyncSocket over CSocket....... Thanking you in advance....... Billar

                P Offline
                P Offline
                palbano
                wrote on last edited by
                #7

                Both of them were written to encapsulate the old 16bit WinSock API. The API was primarily developed to provide non-blocking windows message based mechanism for socket IO since 16 bit windows was a non-preemptive multitasking OS. CAsyncSocket encapsulates the basic API while CSocket provides a blocking version of the same. Today probably the only benefit in using them is to communicate across two MFC applications using serialization of MFC SERIALIZABLE classes. For any other socket use models you are better of using the Winsock2 API.

                "No matter where you go, there your are." - Buckaroo Banzai

                -pete

                1 Reply Last reply
                0
                • B Billar

                  Dear Friends, I have a source code in which there are 2 socket classes i.e. CSocket & CAsyncSocket for both server and client. Codes on the both classes are almost same i.e. having same message handlers of having same code. I would like to know 1. if server or client program can be written by only one class then what is the use of CAsyncSocket together with CSocket? 2. Although CSocket is derived by CAsyncSocket, but if possible please let me know the benifits and uses of AsyncSocket over CSocket....... Thanking you in advance....... Billar

                  B Offline
                  B Offline
                  Billar
                  wrote on last edited by
                  #8

                  Dear All Thanks for the information.... Here, in the above mentioned code, they have used thread. In the Client Program they call a User Message in OnAcceptMessage in both classes and start a TCPIP Thread, through where it send message to Server. Then Server checks for those messages and displays messages accordingly. Here, instead of having thread I wish to Start a Server On Click Button and want to have a Client side which send messages to Server and Server performs just something on depending upon the message contents..... If you r any having such idea or having an example of such kind of code please refer to me. Eagerly waiting for your help.......... Thanks once again to all in advance..... Billar

                  1 Reply Last reply
                  0
                  • J jmkhael

                    The CSocket is a higher level class than the CAsyncSocket. It is easier to manipulate to serialize the data over the network. You dont have to care much about socket notifications, it does all the work for you. But you also lose some flexibility. You can use whatever you need for your application. In order to use CArchive and CSocketFile with an CSocket you just need to create a CSocketFile object (on the heap or on the stack, as you wish)and give it a pointer to your CSocket object. Then when needed you create a CArchive and you map it to a CSocketFile via its constructor and now you are ready to serialize your data on the network by just passing the archive to your serialize function. Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                    V Offline
                    V Offline
                    vcplusplus
                    wrote on last edited by
                    #9

                    This article might help you. http://tangentsoft.net/wskfaq/articles/csocket.html

                    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