Problem in Running the Winsock Client and Server Code Sample

Bill Son Makmur 1 Reputation point

Hello, Microsoft team.
I'm glad I have a chance to ask the Microsoft development team questions.
So, basically, I'm an IoT Engineer, and right now I am doing a project related to sending data (video stream and frames) by using socket.
So. I tried to run the Winsock Client and Server Code Sample from Microsoft documentation.
I didn't encounter any error in compiling both programs but when I tried to execute, the server and then the client, the server's program is not executed anything and the client's program just couldn't be executed,

this is the message from the Client's program when I tried to execute
'usage: C:\Users\project\x64\Debug\project.exe server-name'

This is the output when I executed the server's program.

Do you have any idea on how to solve these issues?

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,567 questions
Remote Desktop
Remote Desktop
A Microsoft app that connects remotely to computers and to virtual apps and desktops.
4,381 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,624 questions
{count} votes

2 answers

Sort by: Most helpful
  1. YujianYao-MSFT 4,281 Reputation points Microsoft Vendor

    Hi @Bill Son Makmur ,

    I tested Complete Winsock Client/Server Code, the picture you uploaded should be the result from Winsock Server Code. This behavior is normal and means that the code is executing as expected. After the breakpoint we can see that the value of iResult is 0, and then observe the code:

     if (iResult != 0) {  
     printf("getaddrinfo failed with error: %d\n", iResult);  
     return 1;  

    Only output if iResult is not equal to 0.

    Similarly, for functions such as socket in the subsequent code, you could enter their documentation by pressing F1 on them. We can clearly find that there is no statement output because neither ListenSocket nor iResult meets the judgment condition of if().

    Best regards,


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

  2. RLWA32 42,796 Reputation points

    As long as the client and server are on the same computer the client can be started using "client.exe localhost". And what you see is the server waiting for a connection.

    0 comments No comments