CoAP 文件传输

以下是基于libcoap, 在ubuntu上,一个shell中运行./coap-server, 另外一个为client.
client的commands 和log 如下:
1.列出资源
2.讲一个28K的文件写入server的example_data
3.读回example_data并写入本地文件

`fei@ubuntu:~/libcoap/examples$ ./coap-client -m get coap://localhost/.well-known/core
</>;title="General Info";ct=0,;if="clock";rt="ticks";title="Internal Clock";ct=0;obs,;ct=0,</example_data>;title="Example Data";ct=0;obs

fei@ubuntu:~/libcoap/examples$ ./coap-client -m put coap://localhost/example_data -t binary -f result.txt
fei@ubuntu:~/libcoap/examples$ ./coap-client -m get coap://localhost/example_data -o result_read.txt
`

以下为wireshark的截图
写入第一包

读回文件

sever回复最后一包, "M" Flag 为0

原文地址:https://www.cnblogs.com/feiwatson/p/15334563.html