You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
"chunk size, (4096 or 8192 is frequently a good match for network buffer "
"sizes), and scanning what you've received for a delimiter."
msgstr ""
"最簡單的改進方法是將訊息的第一個字元表示訊息的類型,並根據訊息的類型來決定訊"
"息的長度。現在你需要使用兩次 ``recv`` - 第一次用於接收(至少)第一個字元來得"
"知長度,第二次用於在迴圈中接收剩下的訊息。如果你決定使用分隔符號的方式,你將會"
"以某個任意的區塊大小進行接收(4096 或 8192 通常是網路緩衝區大小的良好選擇),"
"並在收到的內容中掃描分隔符號。"
#: ../../howto/sockets.rst:231
msgid ""
Expand All
@@ -339,6 +384,9 @@ msgid ""
"of a following message. You'll need to put that aside and hold onto it, "
"until it's needed."
msgstr ""
"需要注意的一個複雜情況是,如果你的通訊協議允許連續發送多個訊息(沒有任何回"
"應),並且你傳遞給 ``recv`` 函式一個任意的區塊大小,最後有可能讀取到下一"
"條訊息的開頭。你需要將其放在一旁並保留下來,直到需要使用的時候。"
#: ../../howto/sockets.rst:237
msgid ""
Expand All
@@ -351,13 +399,21 @@ msgid ""
"not always manage to get rid of everything in one pass. And despite having "
"read this, you will eventually get bit by it!"
msgstr ""
"使用長度作為訊息的前綴(例如,使用 5 個數字字元表示)會變得更複雜,因為(信不"
"信由你)你可能無法在一次 ``recv`` 中獲得所有 5 個字元。在一般使用下,可能不會"
"有這個狀況,但在高負載的網路下,除非使用兩個 ``recv`` (第一個用於確定長度,"
"第二個用於取得訊息的資料部分),否則你的程式碼很快就會出現錯誤。這令人非常頭"
"痛。同樣的情況也會讓你發現 ``send`` 並不總能在一次傳輸中完全清除所有內容。儘"
"管已經閱讀了這篇文章,但最終還是無法解決!"
#: ../../howto/sockets.rst:246
msgid ""
"In the interests of space, building your character, (and preserving my "
"competitive position), these enhancements are left as an exercise for the "
"reader. Lets move on to cleaning up."
msgstr ""
"為了節省篇幅、培養你的技能(並保持我的競爭優勢),這些改進方法留給讀者自行練"
"習。現在讓我們開始進行清理工作。"
#: ../../howto/sockets.rst:252
msgid "Binary Data"
Expand All
@@ -378,10 +434,10 @@ msgstr ""
#: ../../howto/sockets.rst:262
msgid ""
"Socket libraries have calls for converting 16 and 32 bit integers - ``ntohl, "
"htonl, ntohs, htons`` where \"n\" means *network* and \"h\" means *host*, "
"\"s\" means *short* and \"l\" means *long*. Where network order is host "
"order,these do nothing, but where the machine is byte-reversed, these swap "
"thebytes around appropriately."
"htonl, ntohs, htons`` where \"n\" means *network* and \"h\" means *host*,\"s"
"\" means *short* and \"l\" means *long*. Where network order is host order, "
"these do nothing, but where the machine is byte-reversed, these swap the "
"bytes around appropriately."
msgstr ""
#: ../../howto/sockets.rst:268
Expand Down
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.