全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1755
推到 Plurk!
推到 Facebook!

Parameter ATimeout of IdTCPConnection.ReadLn

尚未結案
stickyworm
一般會員


發表:2
回覆:2
積分:0
註冊:2003-05-06

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-05-21 22:53:22 IP:208.60.xxx.xxx 未訂閱
I used the following code in my program to check if there's anything sent through the connection:    IdTCPClient: TIdTCPClient;  ... msg := IdTCPClient.ReadLn(#0, 5);    ReadLn should return an empty string ('') if the peer connection is prematurely closed or a time-out occurs(after 5 millisecond as I set it). But my program simply died there, which made me quite confused.    Thanks a lot for helping. LOOP i cant say goodbye
------
LOOP
i cant say goodbye
wnhoo
高階會員


發表:75
回覆:443
積分:198
註冊:2003-04-22

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-05-22 08:05:47 IP:61.155.xxx.xxx 未訂閱
showmessage(IdTCPClient1.ReadLn);    TRY SEE!        风花雪月 e梦情缘
------
风花雪月 e梦情缘
stickyworm
一般會員


發表:2
回覆:2
積分:0
註冊:2003-05-06

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-05-22 12:25:01 IP:211.108.xxx.xxx 未訂閱
Well yes, by using ShowMessage(IdTCPClient.ReadLn), a Read Timeout message will show up when there's nothing to read. But can you just tell me how to specify a custom time-out value instead of the default one? Whenever I try to do so by specifying a ATimeout parameter, my program dies and fails to show up any message.    Thanks again. ^^) LOOP i cant say goodbye
------
LOOP
i cant say goodbye
stickyworm
一般會員


發表:2
回覆:2
積分:0
註冊:2003-05-06

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-05-22 13:14:45 IP:207.236.xxx.xxx 未訂閱
Oops, I discovered a bug in the TIdTCPConnection component.    In its ReadFromStack, if a timeout occurs, an EIdReadTimeout exception will be raised when ARaiseExceptionOnTimeout is True. Otherwise ReadFromStack performs no additional processing, and uses -1 as the return value for the method. What I want is just the latter. As we all know, the ReadLn method uses the ReadFromStack method, when we specify a custom time-out value in ReadLn, if a time-out occurs, ReadLn will not raise an exception but return an empty string. But that was where my program died dramatically. So I viewed the source code of TIdTCPConnection.ReadLn, and discovered that it mistook the return value -1 of ReadFromStack for 0.  After modification it works fine now. LOOP i cant say goodbye
------
LOOP
i cant say goodbye
Ktop_Robot
站務副站長


發表:0
回覆:3511
積分:0
註冊:2007-04-17

發送簡訊給我
#5 引用回覆 回覆 發表時間:2007-04-26 13:52:42 IP:000.000.xxx.xxx 未訂閱
提問者您好:


以上回應是否已得到滿意的答覆?


若已得到滿意的答覆,請在一週內結案,否則請在一週內回覆還有什麼未盡事宜,不然,
將由版主(尚無版主之區域將由副站長或站長)自由心證,選擇較合適之解答予以結案處理,
被選上之答題者同樣會有加分獎勵同時發問者將受到扣 1 分的處分。不便之處,請見諒。


有問有答有結案,才能有良性的互動,良好的討論環境需要大家共同維護,感謝您的配合。

------
我是機器人,我不接受簡訊.
系統時間:2024-05-01 8:21:15
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!