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. Socket Help!!!

Socket Help!!!

Scheduled Pinned Locked Moved C / C++ / MFC
helpsysadmin
4 Posts 3 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.
  • R Offline
    R Offline
    reddy07
    wrote on last edited by
    #1

    Hi I am trying to create a server that would accept and receive message from multiple client. But i am receiving SOCKET_ERROR while my server seems to accept the multiple connection. Could anyone correct my code. Here is the code I wrote.. CMysocket m_sListenSocket; <pre>void CLocalDlg::OnAccept(void) { CMysocket *pSocket = new CMysocket; if(m_sListenSocket.Accept(*pSocket)) MessageBox("Connection Accepted"); } For receiving: <pre>void CLocalDlg::OnReceive(void) { CMysocket *pSocket = new CMysocket; char *pBuff = new char[1024]; int stlen = 1025; int iRcvd; iRcvd = pSocket->Receive(pBuff, stlen); if(iRcvd ==SOCKET_ERROR) MessageBox("Received socket error"); else MessageBox("Message Received properly"); }

    D T 2 Replies Last reply
    0
    • R reddy07

      Hi I am trying to create a server that would accept and receive message from multiple client. But i am receiving SOCKET_ERROR while my server seems to accept the multiple connection. Could anyone correct my code. Here is the code I wrote.. CMysocket m_sListenSocket; <pre>void CLocalDlg::OnAccept(void) { CMysocket *pSocket = new CMysocket; if(m_sListenSocket.Accept(*pSocket)) MessageBox("Connection Accepted"); } For receiving: <pre>void CLocalDlg::OnReceive(void) { CMysocket *pSocket = new CMysocket; char *pBuff = new char[1024]; int stlen = 1025; int iRcvd; iRcvd = pSocket->Receive(pBuff, stlen); if(iRcvd ==SOCKET_ERROR) MessageBox("Received socket error"); else MessageBox("Message Received properly"); }

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

      Did you preview your post? The <pre> tags are not working.

      reddy07 wrote:

      iRcvd = pSocket->Receive(pBuff, stlen);

      What is pSocket connected to?

      "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

      R 1 Reply Last reply
      0
      • D David Crow

        Did you preview your post? The <pre> tags are not working.

        reddy07 wrote:

        iRcvd = pSocket->Receive(pBuff, stlen);

        What is pSocket connected to?

        "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

        R Offline
        R Offline
        reddy07
        wrote on last edited by
        #3

        Yes, tags are not working. I posted in hurry. I will take care next time when i post. Thanks David!!! Yes, I realized every time OnReceive is invoked new pSocket is created. Then, how to initialize pSocket saying it is previously connected.

        1 Reply Last reply
        0
        • R reddy07

          Hi I am trying to create a server that would accept and receive message from multiple client. But i am receiving SOCKET_ERROR while my server seems to accept the multiple connection. Could anyone correct my code. Here is the code I wrote.. CMysocket m_sListenSocket; <pre>void CLocalDlg::OnAccept(void) { CMysocket *pSocket = new CMysocket; if(m_sListenSocket.Accept(*pSocket)) MessageBox("Connection Accepted"); } For receiving: <pre>void CLocalDlg::OnReceive(void) { CMysocket *pSocket = new CMysocket; char *pBuff = new char[1024]; int stlen = 1025; int iRcvd; iRcvd = pSocket->Receive(pBuff, stlen); if(iRcvd ==SOCKET_ERROR) MessageBox("Received socket error"); else MessageBox("Message Received properly"); }

          T Offline
          T Offline
          Troy Russell
          wrote on last edited by
          #4

          Alo, Pero perdon. Gracias. Adias Troy :laugh: ;P :rolleyes: :omg:

          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