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. Cleint Server - Connection refused.

Cleint Server - Connection refused.

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

    I made one simple client server program. Server Socket created without any error but client program returns WSAECONNREFUSED error. For one confirmation i create another one server socket with same port at that time it's not gives any error. I get confused because it creates two sockets for same port without any error. But this also client gives same error please help me to get out from this issue. Server:

    m_pserversock = new CServerSocket(this);
    bsucessflag= m_pserversock->Create(m_portno,SOCK_STREAM,NULL);
    status=m_pserversock->GetLastError();
    if(bsucessflag)
    {
    // TODO: Server Listen
    bsucessflag= m_pserversock->Listen(5);
    if(bsucessflag)
    {
    //CString Stemp = m_display.GetWindowText(Stemp,m_display.get
    m_display.SetWindowText("Server Listening\r\n");
    }
    else
    {
    m_display.SetWindowText("Unable to Listen\r\n");
    OnDisconnect();
    }
    int a=m_pserversock->m_hSocket;
    }
    else AfxMessageBox("Unable to Create");

        CSocket \*temp;
    temp = new CSocket;
    bsucessflag=temp->Create(m\_portno+1,SOCK\_STREAM,NULL);
    if(!bsucessflag)
    	AfxMessageBox("Error");
    

    CServerSocket,CClientsock is from CSocket. Client:

    m_pClientsock = new CClientsock(this);
    if(m_pClientsock->Create())
    {
    if(m_pClientsock->Connect(dlg.m_Servername,dlg.m_Portno))
    {
    AfxMessageBox("Connected to Server");
    Init();
    m_bIsConnect = TRUE;
    m_Username = dlg.m_Username;
    }
    else
    {
    int istatus=m_pClientsock->GetLastError();

    			AfxMessageBox("Not able to Connect Server");
    			delete m\_pClientsock;
    			m\_pClientsock = NULL;
    		}
    	}
    	else 
    		AfxMessageBox("Not able to Create");
    
    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