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
打開(kāi)瀏覽器,輸入http://192.168.2.101:7681,替換192.168.2.101為自己的服務(wù)器IP地址。出現(xiàn)如下頁(yè)面,測(cè)試成功。
前提:將虛擬機(jī)設(shè)置為橋接模式,使虛擬機(jī)和開(kāi)發(fā)板處于同一局域網(wǎng)內(nèi),確保網(wǎng)絡(luò)連接正常。
1、虛擬機(jī)運(yùn)行服務(wù)端測(cè)試程序
elf@ubuntu:~/work/libwebsockets-main/install/bin$ libwebsockets-test-server
客戶(hù)端命令格式:
libwebsockets-test-client <server address> [--port=<p>] [--ssl] [-k] [-v <ver>] [-d <log bitfield>] [-l]
執(zhí)行如下命令,替換192.168.2.101為自己的服務(wù)器IP地址。
root@ELF1:~# libwebsockets-test-client 192.168.2.101 --port=7681
閱讀全文