| Dart Home | PowerTCP Emulation for .NET | Custom Development | Reply | PowerTCP Emulation for .NET Topics | Forums |
| Author | Forum: PowerTCP Emulation for .NET Topic: Help with Inconsistent Read |
| lim_ah From: Perth, Australia Posts: 3 Member Since: 04/29/05 |
posted October 13, 2006 5:35 AM Im using BeginRecieve and EndRecieve to communicate with a menu driven telnet server. Reading is done by calling BeginReceive (with buffer size of 2048), and when the corresponding EndRecieve is called within a certain time limit it will thus call the BeginRecieve again. When the time is up it is assumed keystrokes are needed to be sent. Using this algorithm some reads result in the screenscrape being inconsistent (where the same point of the menu will have different characters or message structure) ... some not all. Is there anything that can minimise this from occuring ?? Thanks |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted October 13, 2006 12:23 PM When you say "when the corresponding EndRecieve is called within a certain time limit ", you don't mean that you are calling EndRecieve yourself do you? If so, you should not be doing that. If that's not what you mean, then please clarify with an example containing real data so I can understand what you mean. |
| lim_ah From: Perth, Australia Posts: 3 Member Since: 04/29/05 |
posted October 14, 2006 7:14 AM No no, i wait for the EndReceive event to arise first. Basically the algorithm goes as so: Telnet_BeginReceive () { startTimer(); byte[] qbuffer = new byte[2048]; Vt.Telnet.BeginReceive(qBuffer); } Telnet_EndReceive(obj sender,SegmentEventArgs e) { stopTimer(); Terminal.Write(e.Segment.ToString()); string s = ScrapeScreen(Terminal); Telnet_BeginRecieve() } Thus when the timer elapsed say after 10 seconds, the screen is scraped from Vt to see which keys are to be sent. Some examples of the screens being inconsistent are: + Loc OnHand Commit Avail XfSend XfRecv BkOrdr OnOrdr EstD ReOrd Bin + | 01 47 0 47 0 0 0 0 0 | | 01 10 0 10 0 0 0 20 06/04 0 | | 010 10 0 10 0 0 0 20 06/04 0 | | 011 0 0 0 0 0 0 0 0 | |-012---------0-------0--------0------0------0-------0-------0----------0------| +------------------------------------------------------------------------------+ TOTALS 73 0 73 0 0 0 44 and the next being: 1 205/65R15 94V BFG TRACTION TA BK 5 0.00 126.98 + Loc OnHand Commit Avail XfSend XfRecv BkOrdr OnOrdr EstD ReOrd Bin + | 01 5 0 5 0 0 0 0 0 | | 010 4 0 4 0 0 0 0 06/04 0 | | 011 0 0 0 0 0 0 0 0 | | 012 0 0 0 0 0 0 0 0 | +------------------------------------------------------------------------------+ TOTALS 15 0 15 0 0 0 0 Its either caused by a line being missing or certain characters being replaced by others. I noticed while testing that if i had a smaller buffer size (say 512) the errors on the screen are more numerous ... |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted October 16, 2006 8:27 AM You are most likely encountering threading problems. Th End_Receive event fires on a worker thread and may be firing at the same time that your scrape timer is firing. Try setting the SynchronizingObject property of the Telnet control to the Main form in your application and see if that takes care of the issue. |
| lim_ah From: Perth, Australia Posts: 3 Member Since: 04/29/05 |
posted October 16, 2006 11:44 AM One problem is that the Vt`object is running on a seperate thread from the main form ... Would that solution still work? i can't test it by parsing the main form object to the thread due to the program structure. |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted October 16, 2006 2:27 PM I'm not sure. You may want to try a different approach though. I think you would be better off signaling the main form somehow from the End_Receive event rather than relying on the timer method. If you experience any more issues, please email Dave Harry (sales@dart.com) to discuss more advanced support options. Multi-threading issues like this are too complex to troubleshoot here on the forum. |
| Reply | PowerTCP Emulation for .NET Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|