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. CSocket in MFC Console app

CSocket in MFC Console app

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
5 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.
  • S Offline
    S Offline
    Sprudling
    wrote on last edited by
    #1

    I created a console app supporting MFC to create a small IRC bot. However I can't get my CSocket-derived class to work properly. The AfxSocketInit() call is successful, and so is CMySocket::Create() and CMySocket::Connect(). Using classwizard I overloaded the OnRecieve member to let me know when there is something to recieve. I've done all this in a regular Win32 MFC app before, and it worked as it should. In this console app however it (CMySocket::OnRecieve()) just doesn't get called. I know there is data to recieve because when I call it myself there is. I'm really stuck here... :confused: Sprudling

    A 1 Reply Last reply
    0
    • S Sprudling

      I created a console app supporting MFC to create a small IRC bot. However I can't get my CSocket-derived class to work properly. The AfxSocketInit() call is successful, and so is CMySocket::Create() and CMySocket::Connect(). Using classwizard I overloaded the OnRecieve member to let me know when there is something to recieve. I've done all this in a regular Win32 MFC app before, and it worked as it should. In this console app however it (CMySocket::OnRecieve()) just doesn't get called. I know there is data to recieve because when I call it myself there is. I'm really stuck here... :confused: Sprudling

      A Offline
      A Offline
      Andres Manggini
      wrote on last edited by
      #2

      If I recall correctly from my CSocket days (years ago), don't you need a window to use CSocket ?. If this is true, then a console application won't work. Hope this helps. Andres Manggini. Buenos Aires - Argentina.

      S 1 Reply Last reply
      0
      • A Andres Manggini

        If I recall correctly from my CSocket days (years ago), don't you need a window to use CSocket ?. If this is true, then a console application won't work. Hope this helps. Andres Manggini. Buenos Aires - Argentina.

        S Offline
        S Offline
        Sprudling
        wrote on last edited by
        #3

        I can't see how it needs a window? The class basicly works, and I can use it to send and recieve perfectly, but the OnEvent()-functions just doesn't get called by the MFC framework. Do I need a message loop or anything to make it do so? If this isn't possible, how can I check if there is data ready to be recieved, without halting the program if there isn't any? Sprudling

        N L 2 Replies Last reply
        0
        • S Sprudling

          I can't see how it needs a window? The class basicly works, and I can use it to send and recieve perfectly, but the OnEvent()-functions just doesn't get called by the MFC framework. Do I need a message loop or anything to make it do so? If this isn't possible, how can I check if there is data ready to be recieved, without halting the program if there isn't any? Sprudling

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          Asynchronous calls like OnReceive and OnSend need a window! Nish


          Author of the romantic comedy Summer Love and Some more Cricket [New Win]

          1 Reply Last reply
          0
          • S Sprudling

            I can't see how it needs a window? The class basicly works, and I can use it to send and recieve perfectly, but the OnEvent()-functions just doesn't get called by the MFC framework. Do I need a message loop or anything to make it do so? If this isn't possible, how can I check if there is data ready to be recieved, without halting the program if there isn't any? Sprudling

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            You do need a window to receive event notifications like OnReceive. Network events are processed with the same mechanism used to process windows messages. So u need a window to receive those notifications. A console app has no connection with windows.

            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