Problem in Running the Winsock Client and Server Code Sample

Bill Son Makmur 1 Reputation point
2022-05-11T08:58:09.457+00:00

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.
![200899-image.png]1

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

Windows for business Windows Client for IT Pros User experience Remote desktop services and terminal services
Windows for business Windows Server User experience Other
Developer technologies C++
{count} votes

2 answers

Sort by: Most helpful
  1. YujianYao-MSFT 4,296 Reputation points Microsoft External Staff
    2022-05-11T09:41:50.723+00:00

    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);  
     WSACleanup();  
     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,

    Elya


    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 49,536 Reputation points
    2022-05-11T09:20:52.417+00:00

    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.