Win32 websocket sample

MAORVERED MAORVERED 21 Reputation points
2020-10-05T07:20:24.763+00:00

Hello,

I found a wensocket sample code in:
Websocket

But I need few hints:
Is it a server or client ?

I tried running it. It runs and exist without any error.
Does not wait for a client (e.g chrome to connect).
Can you please advise ?

Thank you,
Zvika

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,502 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Strive Sun-MSFT 426 Reputation points
    2020-10-06T06:55:10.297+00:00

    Hello @MAORVERED MAORVERED ,

    Is it a server or client ?

    It is a test sample, which contains client and server.

    As you can see from the code, it uses WebSocketCreateClientHandle and WebSocketCreateServerHandle to create a client side websocket handle and a server side websocket handle.

    // Create a client side websocket handle.  
        hr = WebSocketCreateClientHandle(NULL, 0, &clientHandle);  
        if (FAILED(hr))  
        {  
            goto quit;  
        }  
      
        // Create a server side websocket handle.  
        hr = WebSocketCreateServerHandle(NULL, 0, &serverHandle);  
        if (FAILED(hr))  
        {  
            goto quit;  
        }  
    

    The debugging result of the sample is to use WebSocketSend to send data and use WebSocketReceive to receive data.

    30268-capture.png

    Thank you!

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.

    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.

    0 comments No comments