Free Pascal => Unix => Topic started by: AlanTheBeast on September 25, 2016, 07:47:53 pm
Title: Need to read a simple string stream from an IP address
Post by: AlanTheBeast on September 25, 2016, 07:47:53 pm
Hi,
I don't use Lazarus, just FPC command line (via Lightweight).
I have a nifty app on my iPhone called SensorLog and it will output whatever sensor data from the phone one sets up to an IP address and a set port. I can telnet that to the terminal such as
but I can't get a named pipe or directed pipe to read in the stream.
Is there some "light" unit that will allow me to read the stream?
Something like
- set an IP address and port as a textfile or a stream - read from it until dizzy - close when done
Thanks
Title: Re: Need to read a simple string stream from an IP address
Post by: Phil on September 25, 2016, 07:51:39 pm
Not sure if I follow.
Does an HTTP request using FPC's TFPHTTPClient class work? (fphttpclient unit)
Title: Re: Need to read a simple string stream from an IP address
Post by: AlanTheBeast on September 26, 2016, 12:51:42 am
I don't know Phil - but now that you've pointed me at that unit I'll see what I see!
Title: Re: Need to read a simple string stream from an IP address
Post by: Phil on September 26, 2016, 01:00:49 am
I might have misunderstood what you're doing.
Are you using telnet on a computer as a way to read from the iOS app sends?
I think that for an HTTP request to work, the iOS app would need to act like a Web app running under a Web server. That is, when it receives a request for data, it returns it in a response. From the description on the app store, it appears as though it SensorLog can do that:
I believe iOS includes a Web server (Apache) because I've seen an iOS app that works like a Web app. Perhaps SensorLog is using the server to service the HTTP requests.
Title: Re: Need to read a simple string stream from an IP address
Post by: Thaddy on September 26, 2016, 06:30:00 am
Http should work since it is explicitly supported by SensorLog. see docs in appstore that reads: per HTTP GET/POST.
In that case it should be very easy with TFPHttp and trivial with synapse.
[edit] The httpget example in /packages/fcl-web/examples/httpclient/ works straight out of the box, tested against an apache server. usage: httpget <url> <filename>
function HttpGetText(const URL:string;const Response: TStrings):Boolean;// in httpsend.pas
There's TCP/IP only streaming client example in this blogpost by forum member leledumbo: http://pascalgeek.blogspot.nl/2012/06/encryption-decryption-and-asynchronous.html Scroll-down a bit.