CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    2

    Help needed on CSocket

    I want to use CSocket. but when i called Create() function, it always return 0, i gave the following code fragment here.
    what is the wrong? did i do any mistake? Help is needed. if you can provide me sample code i will be happy.

    CSocket serverSocket, clientConnection;
    if(!serverSocket.Create(4001)){
    m_StaticText.SetWindowText("Server Create error...");
    return;
    }
    if(!serverSocket.Listen()){
    m_StaticText.SetWindowText("Server Listen error...");
    return;
    }
    if(!serverSocket.Accept(clientConnection)){
    m_StaticText.SetWindowText("Server Accept error...");
    return;
    }

  2. #2
    Join Date
    Sep 1999
    Location
    malaysia
    Posts
    191
    Hi,

    Have called AfxSocketInit() somewhere before you start using these objects??...Usually at Initinstance() of your application..

    Hope that helps

    Mustafa
    ______________________________
    To err is human, it's the computer that causes blunders !!!

    DO: Dazzle me with your intelligence
    DON'T : Confuse me with your bullshit

  3. #3
    Join Date
    May 2004
    Posts
    2
    thanks a lot, it's working now.

  4. #4
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    [Moved thread]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured