首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过Netcat将UDP数据包发送到Memcached

通过Netcat将UDP数据包发送到Memcached
EN

Unix & Linux用户
提问于 2018-03-04 09:14:52
回答 1查看 1.6K关注 0票数 1

我试图通过netcat将stats命令发送给memcached,但是,我没有从memcached获得任何东西。

我试过了

代码语言:javascript
复制
echo "stats" > commands.txt
nc -u 127.0.0.1 11211 < commands.txt

我也试过

代码语言:javascript
复制
echo stats | nc -u 127.0.0.1 11211

根据我在Memcached文档第1176行底部所读到的内容,发送命令时可能必须包括

代码语言:javascript
复制
Each UDP datagram contains a simple frame header, followed by data in the
same format as the TCP protocol described above. In the current
implementation, requests must be contained in a single UDP datagram, but
responses may span several datagrams. (The only common requests that would
span multiple datagrams are huge multi-key "get" requests and "set"
requests, both of which are more suitable to TCP transport for reliability
reasons anyway.)

The frame header is 8 bytes long, as follows (all values are 16-bit integers 
in network byte order, high byte first):

0-1 Request ID
2-3 Sequence number
4-5 Total number of datagrams in this message
6-7 Reserved for future use; must be 0

我的问题是,如何使用netcat通过udp将stats命令发送到Memcached?

EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2018-03-04 09:26:46

以下操作正常,必须指定框架标头

代码语言:javascript
复制
printf '\x00\x00\x00\x00\x00\x01\x00\x00stats\r\n' | nc -u 127.0.0.1 11211
票数 2
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/428023

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档