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. why CAsyncSocket always failed while Connect()???

why CAsyncSocket always failed while Connect()???

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminhelptutorialquestion
8 Posts 3 Posters 1 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.
  • A Offline
    A Offline
    ashxly
    wrote on last edited by
    #1

    :eek:I am trying to use CAsyncSocket to connect to the server and wrote the code below: ... CAsyncSocket asocket; asocket.Create();//ok asocket.Connect("server",999);//always failed ... can anyone tell me what's the reason and how to resolve this problem. thanks a lot.

    J M 2 Replies Last reply
    0
    • A ashxly

      :eek:I am trying to use CAsyncSocket to connect to the server and wrote the code below: ... CAsyncSocket asocket; asocket.Create();//ok asocket.Connect("server",999);//always failed ... can anyone tell me what's the reason and how to resolve this problem. thanks a lot.

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

      did u call AfxSocketInit? Papa while (TRUE) Papa.WillLove ( Bebe ) ;

      A 1 Reply Last reply
      0
      • A ashxly

        :eek:I am trying to use CAsyncSocket to connect to the server and wrote the code below: ... CAsyncSocket asocket; asocket.Create();//ok asocket.Connect("server",999);//always failed ... can anyone tell me what's the reason and how to resolve this problem. thanks a lot.

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

        GetLastError() will tell ya

        A 1 Reply Last reply
        0
        • J jmkhael

          did u call AfxSocketInit? Papa while (TRUE) Papa.WillLove ( Bebe ) ;

          A Offline
          A Offline
          ashxly
          wrote on last edited by
          #4

          yes, I called AfxSocketInit() the problem is why CSocket works ok,but CAsyncSocket not? thanks

          1 Reply Last reply
          0
          • M Moak

            GetLastError() will tell ya

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

            thanks for your reply, the error code is 10035 but i want to know what's the difference between CAsyncSocket and CSocket. can you plz told me about that? many many thanks

            M 1 Reply Last reply
            0
            • A ashxly

              thanks for your reply, the error code is 10035 but i want to know what's the difference between CAsyncSocket and CSocket. can you plz told me about that? many many thanks

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

              CSocket does work blocking (with background processing of Windows messages), CAsyncSocket does not block. That's why you get error 10035 "A non-blocking socket operation could not be completed immediately". You should read example code to study CAsnycSocket's concept. In your case you would override OnConnect() handler.

              A 2 Replies Last reply
              0
              • M Moak

                CSocket does work blocking (with background processing of Windows messages), CAsyncSocket does not block. That's why you get error 10035 "A non-blocking socket operation could not be completed immediately". You should read example code to study CAsnycSocket's concept. In your case you would override OnConnect() handler.

                A Offline
                A Offline
                ashxly
                wrote on last edited by
                #7

                Many thanks dear Moak , thanks for your kind advice, and now the problem is gone.

                1 Reply Last reply
                0
                • M Moak

                  CSocket does work blocking (with background processing of Windows messages), CAsyncSocket does not block. That's why you get error 10035 "A non-blocking socket operation could not be completed immediately". You should read example code to study CAsnycSocket's concept. In your case you would override OnConnect() handler.

                  A Offline
                  A Offline
                  ashxly
                  wrote on last edited by
                  #8

                  Many thanks dear Moak , thanks for your kind advice, and now the problem has gone. but i am still not very clear why CSocket could do that? Is not CSocket some kind of async socket?

                  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