[当我通过telnet发送以下序列时,我得到EXPECTED_CRLF:
$ telnet localhost 11300
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
put 0 0 1 4
68 6f 6c 61
EXPECTED_CRLF
UNKNOWN_COMMAND
我以为,当我在telnet中按“ Enter”时,它将发送一个“ CR LF”(https://www.freesoft.org/CIE/RFC/1123/31.htm)
此处是Beantalkd协议:https://github.com/beanstalkd/beanstalkd/blob/master/doc/protocol.txt
我尝试像@Alister Bulman所说的那样切换crlf,但是它没有用:
$ telnet
telnet> toggle crlf
Will send carriage returns as telnet <CR><LF>.
telnet> open localhost 11300
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
put 0 0 1 4
68 6f 6c 61
EXPECTED_CRLF
UNKNOWN_COMMAND
这里的问题是:您可以发送文本而无需将其编码为字节。对于文本“ hola”而言,正确的是4个字节,但是对于“ 68 6f 6c 61”而言,其长度必须为“ 11”个字节。我误解了该协议,因为它被描述为<data>
的“字节序列”。实际上,TCP传递是字节流!
- <data> is the job body -- a sequence of bytes of length <bytes> from the previous line.
所以正确的命令是:
$ telnet
telnet> open localhost 11300
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
put 0 0 1 4
hola
INSERTED 1
put 0 0 1 11
68 6f 6c 61
INSERTED 2