Sign in to follow this  

Is this wrong in Winsock coding?

This topic is 4745 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, Im very new to winsock coding and got this code snippet from an online tutorial
WSADATA WsaDat;
if (WSAStartup(MAKEWORD(1,1), &WsaDat) != 0)
{
   printf("WSA Initialization failed.");
}

as u can tell that sets up the Winsock api, the code in itself is correct (at least I assume from the author). This is valid and no error message is shown when I run it. However if I run it tryin to run it by specifying a version of winsock that dont exist eg. 10.3 or any invalid version like 1.45
WSADATA WsaDat;
if (WSAStartup(MAKEWORD(10,3), &WsaDat) != 0)
{
   printf("WSA Initialization failed.");
}

I still dont get an error like I would if I specified (0,0) for version 0 (which i know is an error). Is this a bug in Winsock api or is it, something that was put into to allow a user to ask for, or negotiate a version of their choice, then the api picks the highest version closest to it? I dont know. Thanks in advance DarkStar UK

Share this post


Link to post
Share on other sites
Docs for WSAStartup.

Quote:

If this version is equal to or higher than the lowest version supported by the DLL, the call succeeds and the DLL returns in wHighVersion the highest version it supports and in wVersion the minimum of its high version and wVersionRequested.

Share this post


Link to post
Share on other sites

This topic is 4745 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this