Valhalla Legends Archive

Programming => General Programming => C/C++ Programming => Topic started by: R.a.B.B.i.T on April 12, 2005, 07:01 PM

Title: Need help on MSVC++ socket error
Post by: R.a.B.B.i.T on April 12, 2005, 07:01 PM
Okay, so I'm using MFC, right?  Well, that's all fine and dandy.  I've got my form, I've got my classes, member variables, all that shit.  My problem, however, is the following:
void void CIde_testDlg::OnGet()
{
tagVARIANT addr;
tagVARIANT port;
addr.pcVal = "valhallalegends.com";
port.intVal = 80;
m_sock.Connect(addr, port);
}
Everything compiles fine, but when I click the "Get" button, a message box pops up and says "Unsupported variant types".  Google and MSDN failed to help me figure out what's going on, so I hope someone here knows.
Title: Re: Need help on MSVC++ socket error
Post by: MyndFyre on April 12, 2005, 07:12 PM
Why are you using VARIANT structures for your data?  Why not just your normal everyday types?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_casyncsocket.3a3a.connect.asp talks about the overloaded CAsyncSocket::Connect method.
Title: Re: Need help on MSVC++ socket error
Post by: R.a.B.B.i.T on April 12, 2005, 08:31 PM
Because I'm still fairly new to MFC, and that's what the control uses (which was created by MFC).
Title: Re: Need help on MSVC++ socket error
Post by: MyndFyre on April 12, 2005, 08:51 PM
Quote from: rabbit on April 12, 2005, 08:31 PM
Because I'm still fairly new to MFC, and that's what the control uses (which was created by MFC).

I guess I still don't understand.  You're not using an actual MFC socket object (CAsyncSocket or CSocket), but another control that was created *using* MFC?

What type is the m_sock variable?
Title: Re: Need help on MSVC++ socket error
Post by: R.a.B.B.i.T on April 12, 2005, 08:58 PM
The m_sock variable is a CMSWinsockControl, which is the only option available.
Title: Re: Need help on MSVC++ socket error
Post by: MyndFyre on April 12, 2005, 09:05 PM
Quote from: rabbit on April 12, 2005, 08:58 PM
The m_sock variable is a CMSWinsockControl, which is the only option available.

Do you *need* to use a control?  MSDN returns nothing when I search for that type.

If you're using MFC, why not just use the built-in CAsyncSocket or CSocket classes?  These are part of MFC.
Title: Re: Need help on MSVC++ socket error
Post by: R.a.B.B.i.T on April 13, 2005, 04:56 PM
Thanks, I don't have any problems now (so far).  I didn't know about those :D