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. could you help me? I need a example about how to using CSocket with mfc

could you help me? I need a example about how to using CSocket with mfc

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++helpquestion
10 Posts 8 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.
  • E Offline
    E Offline
    electric009
    wrote on last edited by
    #1

    I need a simple example Demonstration of the client-side connection service

    T F H D 4 Replies Last reply
    0
    • E electric009

      I need a simple example Demonstration of the client-side connection service

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      can you please search codeproject before posting your question here!

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
      Never mind - my own stupidity is the source of every "problem" - Mixture

      cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

      C 1 Reply Last reply
      0
      • T ThatsAlok

        can you please search codeproject before posting your question here!

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
        Never mind - my own stupidity is the source of every "problem" - Mixture

        cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        Pardon sir, I've found it: CP itz thiz!!!! plz send me code plz plz! :-D

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        1 Reply Last reply
        0
        • E electric009

          I need a simple example Demonstration of the client-side connection service

          F Offline
          F Offline
          fanronghua
          wrote on last edited by
          #4

          That's simple. //CListenSocket头文件 class CListenSocket : public CSocket { public: CListenSocket(HWND hWnd=NULL); HWND m_hWnd; //事件处理窗口 virtual void OnAccept(int nErrorCode); }; //CListenSocket实现文件 #include "ListenSocket.h" CListenSocket::CListenSocket(HWND hWnd){m_hWnd=hWnd;} void CListenSocket::OnAccept(int nErrorCode) { SendMessage(m_hWnd,WM_SOCKET_MSG,SOCKET_CLNT_ACCEPT,0); CSocket::OnAccept(nErrorCode); } ... m_pListenSocket=new CListenSocket(m_hWnd); m_pListenSocket->Create(...); m_pListenSocket->Listen(); ... LRESULT CXxxDlg::OnSocketMsg(WPARAM wParam, LPARAM lParam) { UINT type=(UINT)wParam; switch(type) { case SOCKET_CLNT_ACCEPT: { CSocket* pSocket=new CSocket; if(!m_pListenSocket->Accept(*pSocket)) { delete pSocket; break; } ... } ... } }

          H B 2 Replies Last reply
          0
          • E electric009

            I need a simple example Demonstration of the client-side connection service

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            I know a site that it has some examples for it its name is Codeproject! Simple CSocket Server Application Support Multiple ...[^]

            Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

            J 1 Reply Last reply
            0
            • F fanronghua

              That's simple. //CListenSocket头文件 class CListenSocket : public CSocket { public: CListenSocket(HWND hWnd=NULL); HWND m_hWnd; //事件处理窗口 virtual void OnAccept(int nErrorCode); }; //CListenSocket实现文件 #include "ListenSocket.h" CListenSocket::CListenSocket(HWND hWnd){m_hWnd=hWnd;} void CListenSocket::OnAccept(int nErrorCode) { SendMessage(m_hWnd,WM_SOCKET_MSG,SOCKET_CLNT_ACCEPT,0); CSocket::OnAccept(nErrorCode); } ... m_pListenSocket=new CListenSocket(m_hWnd); m_pListenSocket->Create(...); m_pListenSocket->Listen(); ... LRESULT CXxxDlg::OnSocketMsg(WPARAM wParam, LPARAM lParam) { UINT type=(UINT)wParam; switch(type) { case SOCKET_CLNT_ACCEPT: { CSocket* pSocket=new CSocket; if(!m_pListenSocket->Accept(*pSocket)) { delete pSocket; break; } ... } ... } }

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              You could write: 头文件=Header file 事件处理窗口=Window event handler :-D

              Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

              1 Reply Last reply
              0
              • F fanronghua

                That's simple. //CListenSocket头文件 class CListenSocket : public CSocket { public: CListenSocket(HWND hWnd=NULL); HWND m_hWnd; //事件处理窗口 virtual void OnAccept(int nErrorCode); }; //CListenSocket实现文件 #include "ListenSocket.h" CListenSocket::CListenSocket(HWND hWnd){m_hWnd=hWnd;} void CListenSocket::OnAccept(int nErrorCode) { SendMessage(m_hWnd,WM_SOCKET_MSG,SOCKET_CLNT_ACCEPT,0); CSocket::OnAccept(nErrorCode); } ... m_pListenSocket=new CListenSocket(m_hWnd); m_pListenSocket->Create(...); m_pListenSocket->Listen(); ... LRESULT CXxxDlg::OnSocketMsg(WPARAM wParam, LPARAM lParam) { UINT type=(UINT)wParam; switch(type) { case SOCKET_CLNT_ACCEPT: { CSocket* pSocket=new CSocket; if(!m_pListenSocket->Accept(*pSocket)) { delete pSocket; break; } ... } ... } }

                B Offline
                B Offline
                BangQ
                wrote on last edited by
                #7

                Note how it will be Chinese?:confused:

                1 Reply Last reply
                0
                • H Hamid Taebi

                  I know a site that it has some examples for it its name is Codeproject! Simple CSocket Server Application Support Multiple ...[^]

                  Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                  J Offline
                  J Offline
                  JBAK_CP
                  wrote on last edited by
                  #8

                  There are a few examples here: http://cs.baylor.edu/~donahoo/practical/CSockets/mfc/[^]

                  H 1 Reply Last reply
                  0
                  • J JBAK_CP

                    There are a few examples here: http://cs.baylor.edu/~donahoo/practical/CSockets/mfc/[^]

                    H Offline
                    H Offline
                    Hamid Taebi
                    wrote on last edited by
                    #9

                    Are you sure I need to it? :-D

                    Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                    1 Reply Last reply
                    0
                    • E electric009

                      I need a simple example Demonstration of the client-side connection service

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

                      See here and here.

                      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                      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