CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2002
    Posts
    9

    Why can't I create CSocket derived socket?

    m_pSocket = new CListeningSocket(this);
    if( m_pSocket->Create(SOCKET_PORT) )
    ...
    an error "10093" is got. Can anybody tell me what does that mean? thx

  2. #2
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    3,128
    I did a lookup and found that the code error means "Either the application has not called WSAStartup, or WSAStartup failed. "

    If you are using MFC, it is very likely that you didn't call AfxOleInit() in CWinApp::InitInstance().

    Hope that helps.

  3. #3
    Join Date
    Oct 2002
    Posts
    1,134
    I don't know if AfxOleInit includes WSAStartup. WSAStartup(...) is a routine that loads the WinSock dll, and must be called before you do anything else in WinSock.
    Regards
    Robert Thompson

  4. #4
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    3,128
    Oh no, I am very sorry. I had made an mistake and function I meant should be AfxSocketInit(). This function will call WSAStartup() and ensure that WSACleanup() is called before the program terminates.

    Should be more carefull next time.

  5. #5
    Join Date
    Nov 2002
    Posts
    9
    I got it, thx everyone

  6. #6
    Join Date
    Jun 2000
    Location
    Maryland
    Posts
    181
    Exactlt where in the application do you put that code - AfxSocketInit()?

  7. #7
    Join Date
    Nov 2002
    Posts
    9
    InitInstance()

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