📄 protocol.xml
字号:
<chapter id="protocol"><title>Select Protocol Specification</title><para>This chapter describes the protocol used for communication between the <application>Select</application> daemon and clients.</para><sect1><title>Pseudo EBNF grammar</title><para>This is an approximate grammar for the protocol, written in a kind of EBNF notation.</para><productionset><title>Help Productions</title><production id="list"><lhs>list(x)</lhs><rhs>x ("," x)*</rhs></production><production id="zlist"><lhs>zlist(x)</lhs><rhs>"" | list(x)</rhs></production><production id="strlen"><lhs>strlen(x)</lhs><rhs>'int: length of string x'<lineannotation>Length in bytes</lineannotation></rhs></production><production id="lstring"><lhs>lstring(x)</lhs><rhs>strlen(x) ":" x</rhs></production></productionset><productionset><title>Client Requests</title><production id="open"><lhs><nonterminal>open</nonterminal></lhs><rhs>"open\n"</rhs></production><production id="close"><lhs><nonterminal>close</nonterminal></lhs><rhs>"close\n"</rhs></production><production id="parts"><lhs><nonterminal>part</nonterminal></lhs><rhs>"part:" 'str: key' ":" 'int: strlen' ":" 'str: value' "\n"</rhs></production><production id="classify"><lhs><nonterminal>classify</nonterminal></lhs><rhs>"classify:" 'int: class' ":" 'char: type' "\n"</rhs></production><production id="learn"><lhs><nonterminal>learn</nonterminal></lhs><rhs>"learn:" 'int: class' "\n"</rhs></production><production id="unlearn"><lhs><nonterminal>unlearn</nonterminal></lhs><rhs>"unlearn:" 'int: class' "\n"</rhs></production><production id="delete"><lhs><nonterminal>delete</nonterminal></lhs><rhs>"delete:" 'int: class' "\n"</rhs></production><production id="set"><lhs><nonterminal>set</nonterminal></lhs><rhs>"set:" 'str: variable' ":" 'str: value' "\n"</rhs></production><production id="get"><lhs><nonterminal>get</nonterminal></lhs><rhs>"get:" 'str: variable' "\n"</rhs></production><production id="extended"><lhs><nonterminal>extended</nonterminal></lhs><rhs>"x-" 'str: type' ":" 'int: strlen' ":" 'str: value' "\n"</rhs></production></productionset><productionset><title>Server Answers</title><production id="ack"><lhs><nonterminal>acknowledgment</nonterminal></lhs><rhs>"ok\n" | "error\n"</rhs></production><production id="rank"><lhs><nonterminal>rank</nonterminal></lhs><rhs>"r:" 'int: zlistlen' ":" zlist('int: class') "\n"</rhs></production><production id="score"><lhs><nonterminal>score</nonterminal></lhs><rhs>"s:" 'int: zlistlen' ":" zlist('flt: value') "\n"</rhs></production><production id="classification"><lhs><nonterminal>classification</nonterminal></lhs><rhs><nonterminal>rank</nonterminal> | <nonterminal>score</nonterminal></rhs></production></productionset><productionset><title>Sessions</title><production id="open_request"><lhs><nonterminal>open_request</nonterminal></lhs><rhs><nonterminal>open</nonterminal> <nonterminal>acknowledgement</nonterminal></rhs></production><production id="close_request"><lhs><nonterminal>close_request</nonterminal></lhs><rhs><nonterminal>close</nonterminal> <nonterminal>acknowledgement</nonterminal></rhs></production><production id="simple_request"><lhs><nonterminal>simple_request</nonterminal></lhs><rhs>(<nonterminal>part</nonterminal> | <nonterminal>learn</nonterminal> | <nonterminal>unlearn</nonterminal>) <nonterminal>acknowledgement</nonterminal></rhs></production><production id="classification_request"><lhs><nonterminal>classification_request</nonterminal></lhs><rhs><nonterminal>classify</nonterminal> <nonterminal>classification</nonterminal></rhs></production><production id="session"><lhs><nonterminal>*session*</nonterminal></lhs><rhs><nonterminal>open_request</nonterminal> (<nonterminal>simple_request</nonterminal> | <nonterminal>classification_request</nonterminal>)* <nonterminal>close_request</nonterminal></rhs></production></productionset><productionset><title>Standard Parts</title><production id="pair"><lhs>pair(x, y)</lhs><rhs>x ":" 'int: length of string y' ":" y</rhs></production><production id="text"><lhs><nonterminal>text</nonterminal></lhs><rhs>pair("text", 'str: text')</rhs></production><production id="mail"><lhs><nonterminal>mail</nonterminal></lhs><rhs>pair("rfc822", 'str: email source')</rhs></production><production id="from"><lhs><nonterminal>from</nonterminal></lhs><rhs>pair("from", 'str: from header value')</rhs></production><production id="subject"><lhs><nonterminal>subject</nonterminal></lhs><rhs>pair("subject", 'str: subject header value')</rhs></production><production id="header"><lhs><nonterminal>header</nonterminal></lhs><rhs>pair("header", 'str: header-type' ":" 'str: header-value')</rhs></production><production id="language"><lhs><nonterminal>language</nonterminal></lhs><rhs>pair("language", 'str: language name')</rhs></production></productionset><sect2><title>Comments</title><para>The "open" and "close" requests are usually not necessary, because opening and closing of sessions are handled at lower communication layers.</para><para>The current implementation does not use the "ok" and "error" acknowledgments from the server. Instead the server indicates errors by just dropping the connection. But that should be OK, it probably isn't useful to try to recover from these errors anyway.</para></sect2></sect1><sect1><title>Example Session</title><programlisting>Client> "open\n"Server> "ok\n"Client> "part:text:12:Hello World!\n"Server> "ok\n"Client> "part:from:24:Adam <adam@paradise.org>\n"Server> "ok\n"Client> "classify:0:r\n"Server> "r:3:5,7,2\n"Client> "train:7\n"Server> "ok\n"Client> "close\n"</programlisting></sect1></chapter>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -