HOME - - - - - Lazarus Tutorials TOC - - - - - - Other material for programmers
Delicious Save this on Delicious

A simple TCP/IP Exercise

"Beginner friendly"

file: lt5Nc.htm

This exercise may be simple... but for it to be useful you need to have access to something that may not be easy to come by!

I'll explain that in a moment.

A zip with the sourcecode is available. That comes with the "final product"- a standalone .exe file which you can run without installing, support files, effects on your registry, etc. It allows you to send a command to a web or LAN attached IoT device such as an IPCam, Arduserver, etc. It doesn't monitor "answers" coming back from the device. (For the IPCam you would use it to trigger, say, the saving of an image via the camera's own ability to do FTP or send an email.) (I haven't offered the .exe as a separate download because the other stuff in the .zip only makes it about 10% larger. Just throw it away, if all you want is the .exe)

Open up a web browser.

Put http://bbc.co.uk into the address bar, press return.

The browser should fill with Good Stuff.

You're going to write something very like a browser, but not for looking at the BBC's webpage. And it will always (until you change what is specified, which you can do while the program is running) send the same "thing" (e.g. "http://bbc.co.uk") to the internet.

When you asked the BBC to send the Good Stuff... you SEND something TO the BBC website before you received the Good Stuff back.

There are things you can buy or make which will Do Things when they are sent things the way you sent something to the BBC. For instance, my Arduservers will turn an LED on (so of course, anything that can be turned on can be connected in place of the LED, which is just to demonstrate the principles.) Send something different, and the LED goes off.

Now... we CAN send the "something" with a web-browser.

For one of my Arduservers, you would send....


.. to turn the LED on, and ...


.. to turn the LED off.

But we don't want to have to get out a web browser each time, remember the long code, etc, etc. Wouldn't it be nice if we had a little application like....

app with two buttons...'on'/'off'

Better yet... how about an app that sends the first command every day at, say, 5pm, and sends the other command every day at 10pm.. or whatever times we want?


THAT's what we're going to write an app for here!

We only need Lazarus and Synapse.

By the way... If an Arduserver doesn't suit your wants for a thing to control, how about being able to trigger an IfTTT.com recipe? Or get an IPCam to take a picture? You's still use the app being created in this tutorial.

Most of the "explanation" of how to do what's proposed is incorporated within the sourcecode of LDN008, which you can download with the link at the top of the page. I you don't want to compile it, fear not, an ready-to-use .exe is included in the .zip.

Screenshot, sheepdogguides.com LDN008 IoT controller

You fill in the URL of the device you want to send the instruction to. The ":1202" in the above specifies a port. Often, you don't need to specify one. You'll know, if you do.

The "/led/0" is one of the commands which that particular IoT device responds to.

The two "notes" lines are just scratchpads. What you put there survives a shut down/ restart, though, through the ini file. (Which also manages the data in the other fields. And window size and position.)

The pane at the bottom, currently showing "Prgm start:" provides a log of the application's execution, with "Success!" and "Failure", as appropriate.

   Search this site or the web        powered by FreeFind
  Site search Web search
Site Map    What's New    Search   BEWARE: There is stuff at my other two sites that the search above won't reveal. Go to either site (see links below) and use that site's FreeFind search button.

BEWARE: The search above only visits a selection of my stuff. Go to either of my other sites (see links below) and use that site's FreeFind search button, if you haven't found something you "know is there".

In addition to the tutorials for which this page serves as Table of Contents, I have other sites with material you might find useful.....

My other sites....
Sheepdog Software homepage.
My Arunet homepage.

... and some links to specific pages within them you might want....
You can't "play" all day... learn to use the Libre Office/ Open Office database. Free. Multi-platform.
The Arduino- LOTS of fun, for not much money. And beginner (intelligent beginner) friendly. And good pursuit for kids. Combine programming and electronics!
Designing printed circuit boards the KiCad way. Free. Multi-platform. Long established. PCB-fab houses take native KiCad files.
And lastly... Making maps... how we did it before GPS Indulge me? This discusses a worthwhile, fun (if presented intelligently) activity for kids, which can be undertaken on many levels... a simple 20 minutes, or weeks of engaging activity. (Also known to divert susceptible adults.)

Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, please at least help me with Facebook links, etc (buttons at top of page). If you run an MS-DOS or Windows PC, please visit my freeware and shareware page, try something? Links on your page to this page would also be appreciated, of course!
Click here to visit editor's freeware, shareware page.

   Here is the way to contact the author of these Lazarus/Delphi tutorials, Tom Boyd.

Valid HTML 4.01 Transitional Page WILL BE tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. (Mostly passes. A few problems caused by Google+ and Delicious code.)

If this page causes a script to run, why? Because of things like Google panels, and the code for the search button. Why do I mention scripts? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....