200924441 九、發明說明: 【發明所屬之技術領域】 -種請求應答的通信方法,特別是有關於—種應用在舰端 所運行的應用程式,應用程式與請求端間的資訊傳遞之非同步靖 求應答的通信方法。 【先前技術】 在一般的應用程式為了能達到即時反應的處理,所以多會採 用非同步請求應答(Asynchronous reqUestresponse)的機制。非同步 凊求應答可以利用線程輪詢㈣胞幻與回覆(callback)兩種方式來 達請參考「第la圖」與「第lb圖」所示’其係分別為習知 線程監控架構圖與習知線程運作流程圖。 在「第1a圖」中分別具有請求端110與伺服端120。在「負 la圖」的請求端110具有複數個線程(thread)ln。在請求端⑽^ 具有線程111的輪詢機制,其用以監控請求端11G _服端12丨 ^發达的請求應答是否有回應。其情程ηι的輪躺運作方3 ^己合「第山lb圖」所示,其包括下列步驟:請求端發送複細 _ 1=叫步驟S15Q) ’其中每—個請求分卿應設置—個請才 對於—個應用程式而言,在應用程式中可以具軸^ (ready)。^11 _作狀,_]為:運行(_)、阻塞_罐制 π未端對每_請求線程分別的詢問是否已經接收咖服端的 200924441 回應(步驟S160)。若請求已细垃价 二接收到伺服端的回應,請求端判斷 是否持續此-線程(步驟Sm)。若請求端持續此一線程的話,則 重複步驟輸(步驟S171) 請求雜肖滅此—線程(步驟 S172)。 對於線程111 _詢機制而言,·端㈣需要销地對線 程in的輪詢進行資訊的收集和回應,所以會消耗词服端12〇中 ,運算資源(例如,CPU運算或記憶體等)。而且飼服端12〇回摩 ^線程m都需要耗費部分時間同時線程iu都存在輪詢: D所以不可避免的會出現線程m遺漏信息的情況。 另種非同步凊求應合方式,其係利用回覆機制。請參考「第 ’其係為f知回覆運作流程圖。請求端ικ)送出非同步 ==_至伺服端(步驟_。其中,對請求的控 執:二=移轉到請求端的執行環境_ime),並且請求端的 U 4表錄郝請轉翻他端(麵㈣)。本 咖)。伺服端完成遠射叫後,將^驟 會吟叫請求端的執行環境,並從 达的執行結果(步驟㈣)。 ㈣所傳 回__就是,健剌於崎 飼服請内部會加大資源消耗和系统負擔。如果應用於 【發明内容】 200924441 、_以上的問題,本發明社要目的在於提供—種非同步請 求應Q的通彳5方法,彳寸別有關於—種應用在伺服端所運行的應用 程式之資訊傳遞。 ~ 、為達上述目的’本發明所揭露之非同步請求應答的通信方 法’其包括下列步驟:於請求端中建立相應請求應答的通訊端 (socket)與連料㈣,在每—請求端巾分概置物件池㈣⑽ P〇〇1),肋記錄不_财鱗所相麵該通訊端之連線狀態; _服端議求應答;回傳回_至請麵目應的通訊 知;根據回覆訊息查找物件池中之相應的處理事件。 本發财請求財_ 了通訊端麵接料進行翻步請求 二^作’藉以減輕伺服端與請求端騎細程式請求應答的 連線負«並且保_轉㈣料的稍師完整性。 明如^本發哪徵與實作,魏合圖示作最佳實施例詳細說 【實施方式】 本糾糾了-_決储騎請求端畴畔請求應答的 端^^別是對伺服财所運行的應用程式,翻以應答對請求 分二Γ:請參考「第3a圖」與「第3b圖」所示,其係 明之系統架構圖與本發明之運作流程圖。在「第3a圖」 3】^接Ϊ 〇與飼服端320。在請求射包括有物件池 接埠312編313。娜物是,在本發明中並非 200924441 是線程犯的輪詢或遠端呼叫請求來義制步請求應答。 請求端向伺服端中註冊相應的通訊資訊(步驟S4]〇),使得伺 服端根據軌資·以確認請求鶴欲使_通訊端。於請求端 中建立相應請求的通訊端(步驟。步驟s與步驟⑽分 別疋對凊求端310與飼服端32G進行請求及應答的初始化過程。 其=,通訊端(socket)提供一種應用程式間的通信方法,通訊端主 要是用在兩個不同的應用程式間的信息交換。在翻程式中對每 丄個通賴對應⑦置不同的識別碼。所以應用程式間在進行信息 又換%❺方的應贿式可啸據唯—識別碼來建立其通訊管道。 在通訊端巾更建立麵物〇巾312,以供相應的刺程式進行 通訊。較佳的實施方式更可以視請求的數量在每—個通訊端中建 立多個連接埠312來與飼服端進行通訊。 接著’在每—個請求端巾分別設置物件池(。_ _)(步驟 S43〇h利用物件池311記錄每—個請求所相應的通訊端與連接痒 ^之連驗態。麵錢程巾,判_輯與舰叙連線狀熊 ^驟S’。若請求端3】〇與做端划騎線狀態時,通气端 2㈣服端狗出連線要求。剛續執行烟糊 &求端31G與端32〇之連線狀態。 ^飼服端接收請求(步驟S45〇)。當飼服端完成請求時,由 -合回覆訊息至請求端(步驟S·)。特別值得注意的是, ^ 3】0在發送請求給飼服端32〇後,請求端灿就可以進行 200924441 同、式的計算或資源調用。因為词服端320所採用的是非 别㈣32…㈣的妓咖息給請求端 。月求、31〇而是等待—段時間, 月 可以運行其他的應用程式。 、10亚在此-時間中 根據回覆訊息查找物件財是否有相 S470)。芒早二主土、^ 1 '以白〕處理事件(步驟 )右疋明未鳊31〇從物件池311中杳 理事件時,,长 —4 %、回覆訊息的處 。月衣柒310會調用此一處理事件給 用。執行數據清除手段(步驟s …^用程式使 费… )右疋清求端310所接你糾从 回復乳心無法從物件池311 、 .. 一找到相應的處理事件 310一會執行數據清除手段用以清除回覆訊息。請參考「第3 ^ 所不,其係為本發明之線程運作示意圖。 c回」 本發明在請麵巾制了通訊端與連接埠 應答的運作,私減_服端 非同步請求 服嘀興叫求糕間對應用程 連線負載量。並且保證所取得_料的連續性和完整性。-合、 雖然本發明以前述之較佳實施例揭露如上 定本發明,蝴細_者,在侧她I 内,當可倾許之更動翻飾,因財㈣之專利n 本說明書所附之申請專利範圍所界定者為準。 H 員視 【圖式簡單說明】 第la圖係為習知線程監控架構圖。 第〗b圖係為習知線程運作流程圖。 30 200924441 第2圖係為習知回覆運作流程圖。 第3a圖係為本發明之系統架構圖。 第3b圖係為本發明之運作流程圖。 第3c圖係為本發明之線程運作示意圖。 【主要元件符號說明】 110 請求端 111 線程 120 伺服端 310 請求端 311 物件池 312 連接埠 313 線程 320 伺服端200924441 IX. Invention: [Technical field of invention] - A communication method for request response, especially for an application that runs on the ship, the non-synchronization of information transfer between the application and the requester A communication method for responding. [Prior Art] In general applications, in order to achieve immediate response processing, an asynchronous asynchronous response (Asynchronous reqUestresponse) mechanism is used. The asynchronous request response can be obtained by using the thread polling (4) cell illusion and the callback method. Please refer to the "La Figure" and "The lb diagram" as shown in the figure. The flow chart of the conventional thread operation. There are a requester 110 and a server 120 in "1a". The requesting end 110 of the "negative la map" has a plurality of threads ln. At the requesting end (10), there is a polling mechanism of the thread 111, which is used to monitor whether the requesting end of the requesting end 11G _ server 12 发达 ^ is a response. The trajectory of the course ηι is shown in the figure "Third lb diagram", which includes the following steps: the requester sends a multiplex _ 1 = called step S15Q) 'where each request branch should be set - For an application, you can have an axis (ready) in your application. ^11 _ 状, _] is: run (_), block _ cans π end of the query for each request thread has received the 200924441 response of the coffee server (step S160). If the request has received a response from the server, the requester judges whether or not the thread is continued (step Sm). If the requester continues the thread, the step is repeated (step S171) and the request is terminated (step S172). For the thread 111_inquiry mechanism, the end (4) needs to pin the information and collect and respond to the polling of the thread in, so it will consume the computing resources (for example, CPU operation or memory, etc.). . And the feeding service end 12〇 back to the ^ thread m need to spend part of the time while the thread iu has polling: D so inevitably there will be a situation where the thread m missed information. Another type of asynchronous request is to use the reply mechanism. Please refer to "The first part is the flow chart of the reply process. The request side ικ" sends the asynchronous ==_ to the server (step _. Among them, the control of the request: two = transfer to the execution environment of the requester _ Ie), and the U 4 record of the request side, please turn over his end (face (four)). This coffee). After the server completes the long-range call, it will call the execution environment of the request side, and the execution result from the end (Step (4)). (4) The __ is that the health of the 崎 剌 饲 feed will increase the resource consumption and system burden. If applied to the [invention content] 200924441, _ above, the purpose of the invention is to Providing a non-synchronous request to the Q of the 5 method, the information about the application of the application running on the server. ~, for the above purposes, the invention disclosed in the asynchronous request response The communication method includes the following steps: establishing a communication terminal (socket) and a lining (4) of the corresponding request response in the requesting end, and setting the object pool (4) (10) P〇〇1) in each requesting end, the rib record is not _ The connection status of the communication terminal opposite the financial scale; _ The service end asks for a response; it returns to the _ to the face of the communication knowledge; according to the reply message to find the corresponding processing event in the object pool. The fortune request _ the communication end face receives the tumbling request 2 As a way to reduce the connection between the server and the requester, the request is answered by the negative « and the security of the _ turn (four) material is the integrity of the teacher. Mingru ^ 本 征 征 征 本 本 本 本 本 本 本 本 本 本 本 本 本 本 本Say [Implementation] This has been corrected - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ And "Figure 3b", which is a system architecture diagram and a flow chart of the operation of the present invention. In "3a" 3] ^ Ϊ 饲 and feeding end 320. The request shot includes an object pool interface 312, 313. Nao is, in the present invention, 200924441 is not a threaded poll or a remote call request. The requesting end registers the corresponding communication information with the server (step S4] 〇), so that the servo end confirms the request to make the _ communication terminal according to the trajectory. The communication end of the corresponding request is established in the requesting end (step. Step s and step (10) respectively perform the initialization process of requesting and responding to the requesting end 310 and the feeding end 32G. The = terminal provides an application. Inter-communication method, the communication terminal is mainly used for information exchange between two different applications. In the program, each pair of placards corresponds to 7 different identification codes, so the information between the applications is changed again. The party's bribery can be used to establish its communication pipeline based on the identification code. In the communication end towel, a face towel 312 is created for communication by the corresponding stab program. The preferred embodiment can be requested. The number establishes a plurality of ports 312 in each communication terminal to communicate with the feeding end. Then 'set the object pool (.__) in each requesting end towel (step S43〇h records with the object pool 311) Each communication request corresponds to the communication end and the connection itch ^ even the test status. Face money towel, judge _ series and ship Syria connection line bear ^ S S. If the request end 3] 〇 and do the end line In the state, the ventilating end 2 (four) serving the dog out of the line to Just continue to execute the smoke paste & the end 31G and the end 32 〇 connection status. ^ Feeding end receiving request (step S45 〇). When the feeding end completes the request, the reply message is sent to the requesting end ( Step S·). It is particularly noteworthy that ^ 3]0 can send a request to the feeding end 32 ,, then request the end can be used for the calculation of the same type or the resource call of 200924441. Because the word service end 320 is used Yes or No (4) 32... (4) 妓 妓 给 请求 请求 。 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月 月S470). Mang early two main soil, ^ 1 'white] event (step) right 疋 明鳊31〇 from the object pool 311 in the event, long - 4%, reply to the message.柒310 will call this processing event for use. Execute the data clearing means (step s ... ^ use the program to make a fee...) Right 疋 求 求 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 310 The corresponding processing event 310 will perform a data clearing method to clear the reply message. Refer to "3^^, which is a schematic diagram of the thread operation of the present invention. c back" The present invention makes the operation of the communication terminal and the connection response in the face towel, private reduction _ server-side asynchronous request service 嘀The amount of load on the application line is determined, and the continuity and integrity of the obtained material are ensured. Although the present invention is disclosed in the above preferred embodiment, the present invention is as described above. In the case of I, when the pledge is changed, the patent of the financial (4) is defined by the scope of the patent application attached to this specification. H 者 [Simplified description of the drawing] The first picture is the conventional thread monitoring Architecture diagram. The diagram is a flow chart of the conventional thread operation. 30 200924441 Figure 2 is a flow chart of the conventional reply operation. Figure 3a is a system architecture diagram of the present invention. Figure 3b is a flow chart of the operation of the present invention. Figure 3c is a schematic diagram of the thread operation of the present invention. [Main component symbol description] 110 Requester 111 Thread 120 Servo terminal 310 Request side 311 Object pool 312 Connection 埠 313 Thread 320 Server