Sep 6, 2017 at 5:42am UTC
I am new in c++ and trying to create a UDP socket in windows. i have written following code:
if (WSAStartup(MAKEWORD(2,2),&wsa) != 0)
cout<<"Failed in socket config"<<endl;
but this if statement is not getting executed. Please guide me what wrong have i done.
Last edited on
Sep 6, 2017 at 6:37am UTC
Sep 7, 2017 at 9:07am UTC
The problem is that the statement
is not getting executed and not returning any value.
Sep 7, 2017 at 10:09am UTC
What evidence do you have that it isn't being executed?
What evidence do you have that it is "not returning any value"?
Have you tried stepping through your code in a debugger, to confirm whether or not the function is being called?
Sep 7, 2017 at 10:52am UTC
Do you call
Actually I'd suggest that you place the statement on top of the main function.
Sep 7, 2017 at 12:15pm UTC
What do you mean by not getting executed? If the message "Failed in socket config" is not being displayed then that means the WSAStartup() returned 0 and was successful. If you mean it's not being tested, then place a breakpoint somewhere in your code and step through each line carefully.