question

BillSonMakmur-8466 avatar image
0 Votes"
BillSonMakmur-8466 asked YujianYao-MSFT commented

Problem in Running the Winsock Client and Server Code Sample

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-serverc++remote-desktop-client
image.png (4.3 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Have you tried starting the server first and then starting the client as I suggested in my answer by passing the localhost parameter?

0 Votes 0 ·
RLWA32-6355 avatar image
0 Votes"
RLWA32-6355 answered RLWA32-6355 edited

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

YujianYao-MSFT avatar image
1 Vote"
YujianYao-MSFT answered YujianYao-MSFT commented

Hi @BillSonMakmur-8466,

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @BillSonMakmur-8466,

May I know if you have got any chance to check my answer? If the answer is the right solution, please click "Accept Answer", It will also help others to solve a similar issue.

0 Votes 0 ·