Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Assertion on CSocketFile construction

Posted on 2000-04-08
5
Medium Priority
?
521 Views
Last Modified: 2013-11-20
Hi,
i have this code:

      CSocket sock;
      sock.Create();
      sock.Connect("localhost",80);
--->      CSocketFile file(&sock);
      CArchive in(&file,CArchive::load);
      CArchive out(&file,CArchive::store);

and i get this debug assertion on the marked line:
SOCKCORE.CPP, line 964:
      ASSERT(m_pSocket->m_hSocket != INVALID_SOCKET);

(m_pSocket is &sock)

and two other ones 4 lines later:
      ASSERT(m_pSocket->GetSockOpt(SO_TYPE,&nType,&nTypeLen));
      ASSERT(nType == SOCK_STREAM);

after that it crashes... of course the http server is running.
any clues?
0
Comment
Question by:Chris1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Expert Comment

by:sneedwt
ID: 2696612
Did you check the return code from the Connect & create calls?  The assertion you're getting basically states that the socket is not valid, thus the association is failing.  My guess is that the Sock Connect call is failing.  Try using the nErr=sock.GetLastError() and looking up the error code.  This might give us more info.
0
 

Author Comment

by:Chris1
ID: 2696688
Hey sneedwt,
yes there is a problem, but with .Create, GetLastError returns 10093 and of course connect fails, too (10022)
I traced it back to this line in CAsyncSocket::Socket():

m_hSocket = socket(nAddressFormat,nSocketType,nProtocolType);

(nAddressFormat=2; nSocketType=1; nProtocolType=0)

This fails (m_hSocket stays INVALID_SOCKET), but i don't know why...
0
 
LVL 23

Accepted Solution

by:
chensu earned 400 total points
ID: 2696825
Call the AfxSocketInit function in your CWinApp::InitInstance override to initialize Windows Sockets.
0
 
LVL 23

Expert Comment

by:chensu
ID: 2696826
The error code 10093 is WSANOTINITIALISED.
0
 

Author Comment

by:Chris1
ID: 2697462
Thanks, I forgot that =)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question