elf@ubuntu:~/work$ unzip libwebsockets-main.zip
elf@ubuntu:~/work$ cd libwebsockets-main/
elf@ubuntu:~/work/libwebsockets-main$ mkdir build
elf@ubuntu:~/work/libwebsockets-main$ mkdir install
elf@ubuntu:~/work/libwebsockets-main$ cd build/
elf@ubuntu:~/work/libwebsockets-main/build$ cmake -DCMAKE_INSTALL_PREFIX=../install ..
elf@ubuntu:~/work/libwebsockets-main/build$ make
elf@ubuntu:~/work/libwebsockets-main/build$ make install
elf@ubuntu:~/work/libwebsockets-main/build$ cd ../install/bin/
elf@ubuntu:~/work/libwebsockets-main/install/bin$ ls
libwebsockets-test-client libwebsockets-test-lejp
libwebsockets-test-server libwebsockets-test-server-extpoll
elf@ubuntu:~/work/libwebsockets-main/install/bin$ libwebsockets-test-server
打开浏览器,输入http://192.168.2.101:7681,替换192.168.2.101为自己的服务器IP地址。出现如下页面,测试成功。
前提:将虚拟机设置为桥接模式,使虚拟机和开发板处于同一局域网内,确保网络连接正常。
1、虚拟机运行服务端测试程序
elf@ubuntu:~/work/libwebsockets-main/install/bin$ libwebsockets-test-server
客户端命令格式:
libwebsockets-test-client <server address> [--port=<p>] [--ssl] [-k] [-v <ver>] [-d <log bitfield>] [-l]
执行如下命令,替换192.168.2.101为自己的服务器IP地址。
root@ELF1:~# libwebsockets-test-client 192.168.2.101 --port=7681
2024年7月11日
Categories: