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地址。出現(xiàn)如下頁面,測試成功。
前提:將虛擬機設置為橋接模式,使虛擬機和開發(fā)板處于同一局域網(wǎng)內(nèi),確保網(wǎng)絡連接正常。
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]
執(zhí)行如下命令,替換192.168.2.101為自己的服務器IP地址。
root@ELF1:~# libwebsockets-test-client 192.168.2.101 --port=7681
閱讀全文