Recent

Author Topic: Collecting telnet server responses using lnet.  (Read 5617 times)

cov

  • Sr. Member
  • ****
  • Posts: 250
Collecting telnet server responses using lnet.
« on: October 18, 2011, 04:08:02 pm »
I am trying to telnet to connect to a TiVo DVB-T device.

When I send the device a "GET" request, the device responds with several packets.

However, lnet will only get the first one.

Is there some way I can get lnet to wait for all packets to be received?

I am simply sending the "GET" command

Code: [Select]
Telnet.SendMessage('GET /tvnb?sessionid='+sessID+msg+' HTTP/1.1' + #13#10 + #13#10);
And then I'm getting the response with

Code: [Select]
procedure TFormMain.TelnetReceive(aSocket: TLSocket);
var s: string;
begin
  if Telnet.GetMessage(s) > 0 then
    begin
      MemoText.Append(s);     
    end;
end;

Normally all the header information is carried in the first packet and the data is carried in subsequent packets, but I am only able to read the first packet, although Wireshark tells me that the data packets are being sent too.

cov

  • Sr. Member
  • ****
  • Posts: 250
Re: Collecting telnet server responses using lnet.
« Reply #1 on: October 20, 2011, 05:37:32 pm »
Hmmm.

Okay, to clarify, I send this to the device:
Quote
GET /tvnb?sessionid=0000001400c2002900&op=channellist&withrating=1 HTTP/1.1

This is actually Frame 73 of the exchange.

The device then sends back Frame 74 which is 66 bytes, followed by Frame 75 which contains 85 bytes of data (which I can access using Telnet.GetMessage(s);):
Quote
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 892
X-1seg-Result: 14

Frame 76 (66 bytes) is then sent to the device, followed by Frame 77, also 66 bytes.

The device then responds with Frame 78 Frame 79, Frame 80, Frame 81, Frame 82 and Frame 83 (each containing 74 bytes), before it finally sends Frame 84 which containst the data I'm interested in, namely 892 bytes of data:
Quote
1_1_cbms://thomson.net/service/105|00|3|1|||0|1|en|Sony Max
1_1_cbms://thomson.net/service/111|00|3|1|||0|1|en|E! Entertainment Mobile
1_1_cbms://thomson.net/service/108|00|3|1|||16|1|en|Africa Magic
1_1_cbms://thomson.net/service/109|00|3|1|||0|1|en|Channel O
1_1_cbms://thomson.net/service/107|00|3|1|||0|1|en|TRACE Urban
1_1_cbms://thomson.net/service/104|00|3|1|||0|1|en|SuperSport Blitz
1_1_cbms://thomson.net/service/101|00|3|1|||0|1|en|SuperSport 1
1_1_cbms://thomson.net/service/103|00|3|1|||0|1|en|SuperSport 2
1_1_cbms://thomson.net/service/102|00|3|1|||0|1|en|SuperSport 3
1_1_cbms://thomson.net/service/113|00|3|1|||0|1|en|SuperSport 4
1_1_cbms://thomson.net/service/110|00|3|1|||0|1|en|eNews
1_1_cbms://thomson.net/service/112|00|3|1|||0|1|en|CNN
1_1_cbms://thomson.net/service/106|00|3|1|||0|1|en|Cartoon Network
1_1_cbms://thomson.net/service/115|00|3|1|||18|1|en|M-Net Series

I want to know how I can access this data. Telnet.GetMessage(s) does not give it to me.

I though that it may be an issue with the string, 's' containing a null value which would truncate it, but the actual data doesn't contain any such null character. If I can access Frame 75 using GetMessage, why can I not access Frame 84?

Almindor

  • Sr. Member
  • ****
  • Posts: 412
    • http://www.astarot.tk
Re: Collecting telnet server responses using lnet.
« Reply #2 on: November 03, 2011, 03:03:35 pm »
This may be a FPC issue with strings, try using .GET instead of .GETMESSAGE to see if it differs.

cov

  • Sr. Member
  • ****
  • Posts: 250
Re: Collecting telnet server responses using lnet.
« Reply #3 on: November 28, 2011, 09:57:55 am »
Hi Almindor,

Thanks for the response.

Is there anywhere I can get the syntax for implementing the GET function?

Many thanks

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Collecting telnet server responses using lnet.
« Reply #4 on: November 28, 2011, 11:39:08 am »
FYI, you can also have a look at this small telnet client implemented using synapse: http://wiki.lazarus.freepascal.org/Synapse#Requirements
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018