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. Need help on socket progrmming

Need help on socket progrmming

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
2 Posts 2 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.
  • K Offline
    K Offline
    Kiran Pinjala
    wrote on last edited by
    #1

    I have class CMySock derived from CAsyncSocket and that class has a member as CMySock *pSock; CMySock's object is created and kept in listen mode.When a connection reqest comes and CMySock's OnAccept() is called. There I want to connect to another system with pSock. and my code for that is if(!(m_pSrcClientSocket->m_pDestClientSocket)->Create()) { MessageBox("Falied to create a socket"); } else { if(!(m_pSrcClientSocket->m_pDestClientSocket)->Connect(rs.GetAt(0),port)) {// Here its failing to connect and gives an error WSAEWOULDBLOCK int err = GetLastError(); MessageBox("Failed to connect to Connect"); } else { // do something. } } if the pointer is of CSocket instead of CMySock its connecting well. I want to user CMySock only. How to overcome this problem. Please help. Thank you

    KIRAN PINJARLA

    F 1 Reply Last reply
    0
    • K Kiran Pinjala

      I have class CMySock derived from CAsyncSocket and that class has a member as CMySock *pSock; CMySock's object is created and kept in listen mode.When a connection reqest comes and CMySock's OnAccept() is called. There I want to connect to another system with pSock. and my code for that is if(!(m_pSrcClientSocket->m_pDestClientSocket)->Create()) { MessageBox("Falied to create a socket"); } else { if(!(m_pSrcClientSocket->m_pDestClientSocket)->Connect(rs.GetAt(0),port)) {// Here its failing to connect and gives an error WSAEWOULDBLOCK int err = GetLastError(); MessageBox("Failed to connect to Connect"); } else { // do something. } } if the pointer is of CSocket instead of CMySock its connecting well. I want to user CMySock only. How to overcome this problem. Please help. Thank you

      KIRAN PINJARLA

      F Offline
      F Offline
      Frank K
      wrote on last edited by
      #2

      Hi, why would you connect to another system at function OnAccept()? CMySock::OnAccept() { CMyClientSock *NewClientSock = new CMyClientSock(); Accept( NewClientSock, NULL, NULL ); //--> now the NewClientSock object is connected to the new incoming connection, you don't need construct / connect any object. } HTH Frank

      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