ICS has a large number of sample application whose primary purpose is to testall the components and to learn about using those components and how to usethem in your own applications. There are often several samples for a singleprotocol with different purposes, so this section should help get you startedchoosing the components and samples for your internet project.
ICS often offers low and high level versions of components, the former allowyour application to send the various commands used by the protocol but youneed to send those commands in the correct order often dependent upon theresult from earlier commands, so you need to understand the protocol, buthave control over the commands. The high level components are quicker andeasier to implement because they hide most of the protocol and offer complexmethods instead such as download a file, they often include extra functionality.
Historically, most ICS components are available on non-SSL and SSL versions,these notes assume you are using SSL/TLS components which are often essentialtoday. Note most low level component need SSL/TLS adding using an SslContextand need SSL certificate chain checking added to applications, while thehigher level components mostly already include the SslContext and chainchecking and hide much of the SSL/TLS complexity making them faster toimplement and easier to maintain as SSL changes.
The SSL sample OverbyteIcsSnippets contains small samples of codes for FTP,HTTP, sockets and email. The unit includes several almost self containedmethods each implementing a single functions, which are hopefully easier tofollow than the normal samples used to develop ICS components and which oftenbecome very complicated due to all the different functionality supported. Thesnippets are heavily documented to try and explain usage.
Most of the snippets access Magenta Systems Ltd public ICS web and FTP serversand should just work without change, except for FTP uploading where you willneed to request an account by emailing del...@magsys.co.uk. Snippets availableinclude:
TSslHttpCli in unit OverbyteIcsHttpProt is the low level HTTP protocol clientthat is tested using sample OverbyteIcsHttpsTst. It has buttons for GET and HEADcommands and allows numerous SSL parameters to be specified. POST requests aretested with samples OverbyteIcsHttpPost and OverbyteIcsHttpPg. Other unitscontaining components assisting HTTP include OverbyteIcsHttpCCodZLib,OverbyteIcsHttpContCod, OverbyteIcsCookies, OverbyteIcsMimeUtils,OverbyteIcsFormDataDecoder, OverbyteIcsCharsetUtils, OverbyteIcsMsSslUtils,MIME with sample OverbyteIcsMimeDemo, SSL certificate chains with sampleOverbyteIcsMsVerify. Note TSslHttpCli requires an SslContext for SSLconfiguration. Note HTTP clients do not need SSL/TLS certificates, butgenerally should check the certificate chains received from HTTPS serversto ensure they are talking to the correct servers.
TSslHttpRest in unit OverbyteIcsSslHttpRest is the high level HTTP protocolclient that has additional methods and properties for making GET, POST, PUTand HEAD REST (REpresentional State Transfer) client requests, but canstill do everything TSslHttpCli does. It includes a TRestParams class tobuild and encode GET/PUT/POST parameter strings. It also includes SSLconfiguration and certificate validation with a root bundle, SSL sessioncaching, content compression, content code page decoding, persistentcookies, Json handling, logging and client SSL certificate support. Theresome REST examples TDnsQueryHttps, TIcsSms, TIcsTwitter and TIcsRestEmail.All tested using sample OverbyteIcsHttpRestTst.
TRestOAuth in unit OverbyteIcsSslHttpOAuth handles OAuth1/2 authenticationusing either embedded EdgeBrowser or TWebBrowser to display the logins webpages, or they can be viewed using an external browser. The unit supportsvarious Microsoft User Authorities for corporate accounts. Note OAuth1/2 userequires a developer application account at Google or Microsoft, or otherproviders which includes Ids and secrets that need to be securely stored.
TIcsHttpMulti in unit OverbyteIcsHttpMulti is another high level HTTP clientthat allows downloading of multiple files from an HTTP server using full URLs,or listed by parsing links from a web page, using a single function call. Italso includes SSL configuration and certificate validation with a root bundle.Tested using sample OverbyteIcsXferTst.
TSslWebSocketCli in unit OverbyteIcsWebSocketCli is WebSocket client componentthat descends from TSslHttpRest so most of it's properties and events are common,but there are new methods and events to access WebSocket servers using ws:// orwss:// URLs. WebSocket is a full duplex TCP protocol for web servers to supportinteractive web pages, typically dynamic updating such as chat sessions, spellcheckers as you type, search hints, etc.
ICS has a visual web browser sample FrameBrowserIcs which needs the HtmlViewercomponent to be installed, which will view simple web pages that don't needJavascript, it logs both HTTP and HTML protocol and can be very useful fordebugging.
There are two SSL samples OverbyteIcsHttpsTst and OverbyteIcsHttpRestTstthat illustrate HTTP GET and POST requests, authentication including OAuth2,file uploading and downloading, cookies, certificate chain verification,content encoding and decoding and WebSockets with a chat demo.
There are some older non-SSL demos for console and DLL and threads, seesamples OverbyteIcsConHttp, OverbyteIcsHttpAsp and OverbyteIcsHttpThrd.Another sample OverbyteIcsJoseTst can be used to test Json ObjectSigning (Jose) functions often used for REST requests, URL encoding anddecoding and display of Json and XML data.
TSslHttpServer in unit OverbyteIcsHttpSrv is the main web server, testedwith sample OverbyteIcsSslWebServr, while TSslHttpAppSrv in unitOverbyteIcsHttpAppServer adds session support and page handlers for creatingdynamic page web applications tested with sample OverbyteIcsSslWebAppServer.These servers only listen on one IP address and port, but you use multiplecomponents for multiple listeners sharing the same events. Note TSslHttpServerand TSslHttpAppSrv require an SslContext for SSL configuration. The samplesare full web servers with a lot of SSL configuration options for an SSL/TLScertificate, note HTTPS servers require an SSL certificate and will not startwithout one. Both samples include a number of dynamic web pages to illustratebasic web server facilities, including a contact form that sends email.
There is a third more advanced HTTP sample OverbyteIcsSslMultiWebServwhich configures TSslHttpAppSrv differently using collections ofIcsHosts properties. This allows the web server to listen on multipleIP addresses and ports at the same time, and to support multiple hostson the same IP address serving different page content (as do mostweb servers). IcsHosts allow different SSL/TLS certificates to bespecified for each host using built-in SslContexts, will automaticallycreate self signed SSL/TLS certificates so the server can start, and willthem order free SSL/TLS certificates from Let's Encrypt (provided runningon the public internet), and re-order them every three months before theyexpire. IcsHosts can accept server certificates as PEM or PFX files, orfrom the Windows Certificate Store (but not from USB dongles). The sampleOverbyteIcsSslMultiWebServr is different to most ICS samples in having aminimal GUI and being entirely configured using an INI file, it is reallydesigned to be built as a Windows service application to run unattendedin background. It includes a separate web log for each host, and willsend emails when it starts and stops. It also includes some anti-hackingtests and will block abusive IP addresses. The sample is based on acommercial web server.
Sample OverbyteIcsDDWebService is very similar to OverbyteIcsSslMultiWebServbut designed as a Windows service, although it will also run as a GUI fordebugging. It requires DDService service framework to be installed. It alsoincludes a REST server with simple lookup responses from a SQL database, whichrequires DISQLite3 to be installed.
The fifth web server is TSimpleWebSrv in unit OverbyteIcsSslHttpOAuth whichis a lightweight server with minimal functionality designed for embeddingin applications needing OAuth2 or SSL/TLS certificate ordering that requireaccess to web server to check a host exists. It has a single event thatpresents a request and returns a response. It supports SSL with IcsHosts.There is no sample, but it is used by other ICS components.
TSslFtpClient in unit OverbyteIcsFtpCli is the low level FTP client that istested with sample OverbyteIcsSslFtpTst. It has about 50 buttons the test thevarious FTP commands in various ways, and allows numerous SSL parameters tobe specified. Note TSslFtpClient requires an SslContext for SSL configuration.Other older FTP samples include OverbyteIcsBasFtp, OverbyteIcsConFtp,OverbyteIcsFtpAsy and OverbyteIcsFtpMulti.
TIcsFtpMulti in unit OverbyteIcsFtpMulti is a high level FTP client that indexes,uploads or downloads single or multiple files automatically, without needingto understand most FTP commands. One function indexes files and directorieson an FTP server building a list compatible with the TIcsFileCopy componentthat indexes Windows directories, allowing local and remote directories tobe compared and files FTP uploaded or downloaded so they match. It alsoincludes SSL configuration and certificate validation with a root bundle,SSL session caching and logging. Use the sample OverbyteIcsXferTst to testTIcsFtpMulti.
TSslFtpServer in unit OverbyteIcsFtpSrv is the FTP server, tested usingsample OverbyteIcsSslFtpServ. The FTP server only listens on one IP addressand port, but you use multiple components for multiple listeners sharing thesame events. Note TSslFtpServer usually requires an SslContext for SSLconfiguration. The sample is a full FTP server for file uploads anddownloads, with a lot of SSL configuration options for the SSL/TLScertificate and will not start without one.
795a8134c1