Libwebsocket client example

后端 未结 2 2039
不思量自难忘°
不思量自难忘° 2021-02-01 07:39

I am trying to find a example which will explain me how to implement Client using libwebsocket, But I didn\'t get any convincing code. Is there any link that I can refer to?

2条回答
  •  余生分开走
    2021-02-01 08:36

    I have code a simple echo server and client using libwebsockets in pure C.

    The server side will do echo after it received the data from client.

    The client side will write a hello message to server after the connection is established. Then after 2 seconds sleep, the client will call libwebsocket_callback_on_writable. You can see how it works.

    I just upload the code on my Google drive.

    My google drive link

    You can compile the code by using below commands in the Terminal.

    gcc example-server.c -o example-server -lwebsockets
    
    gcc example-client.c -o example-client -lpthread -lwebsockets
    

    Or, just use make on Terminal.

提交回复
热议问题