Socket in windows

Hi all,

I am new in c++ and trying to create a UDP socket in windows. i have written following code:

bool socket_udp::vdcu_socket_config()
if (WSAStartup(MAKEWORD(2,2),&wsa) != 0)
cout<<"Failed in socket config"<<endl;
return false;
return true;

but this if statement is not getting executed. Please guide me what wrong have i done.
Last edited on
That means WSAStartup(...) returns 0 which is ok. See:

MSDN wrote:
If successful, the WSAStartup function returns zero.
The problem is that the statement


is not getting executed and not returning any value.
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?
Do you call vdcu_socket_config() at all?

Actually I'd suggest that you place the statement on top of the main function.
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.
Topic archived. No new replies allowed.