-
Winsock Problems
Im just bearly getting use to using VC++ and was woundering if any of you could help me. Im making a program. A simple one. that should connect to itself and send a message when it does. I have turned my winsock to a veriable (m_winsock1) and I Try to use the command m_winsock1.connect("127.0.0.1", 1234); And of course I get an error when comiling.
error C2664: 'Connect' : cannot convert parameter 1 from 'char [10]' to 'const struct tagVARIANT &'
Reason: cannot convert from 'char [10]' to 'const struct tagVARIANT'
No constructor could take the source type, or constructor overload resolution was ambiguous
Any hints?
-
-
What? did I post this on the wrong forum or something?
-
As far as I can tell, you are trying to pass a string into a function that wants a VARIANT. C++ VARIANTS do not work like VB ones, with automatic type conversion. You must load the string into a VARIANT first, then use a conversion function to pass into the function.
Z.
-
Variants aren't even intrinsic to C++.
The closest it has is a union, but that still assumes you know what type you're reading out of it - it won't convert for you.
VARIANT is part of COM, I think (it's there for pointerless languages I think).
-
i couldn't get winsock to work on my comp
i followed a few tutorials, try this:
Code:
//i think this is how it goes
char cIP[4]={'127','0','0','1'};
unsigned short sPort = 1234;
try passing the parameters using those names, because i did it that way, and it didnt give me any problems.
-
cogman
thanx. I had my bro come and try and figure it out. we decided it would be easier to do it the c++ way and not the VB way.