How to communicate with CEF via Sockets - delphi

How can I communicate with CEF via Indy Sockets through Remote debugging protocol?
As described here: https://developers.google.com/chrome-developer-tools/docs/debugger-protocol

I made a Proof of Concept for DWS (pascal to javascript compilation, as used in Smart Mobile Studio) some time ago:
https://code.google.com/p/asmprofiler/source/browse/#svn%2Ftrunk%2F-Other-%2FRemoteDebuggerDWS
You can use my Indy 10 websocket (and socket.io!) components from here:
https://github.com/andremussche/DelphiWebsockets

The API currently requires using the WebSocket protocol which is not supported in Indy. The API documentation page contains this note:
Note that we are currently working on exposing an HTTP-based protocol
that does not require client WebSocket implementation.
There are WebSocket client libraries available for Delphi both free and commercial (some use Indy as their internal TCP library).
You will also need a JSON library, available in newer Delphi versions and also as free open source (for example SuperObject and lkJSON).

Related

Http Server on a Win32 Application [duplicate]

This question already has answers here:
Indy 10 Http Server sample
(2 answers)
Closed 9 years ago.
How to write a desktop Delphi 7 Win32 Apps with embedded Http server something like Media Player Classic with Web Interface. I need a standalone HTTP server to be launched from user's browser to a url e.g. http://:/ and request using a GET or POST and then responded from Delphi app.
TCP/IP libraries usually comes with demo projects.
For example http://synapse.ararat.cz/doku.php/public:howto:httpsserver
There are also larger frameworks that provide HTTP server just as one of their services (which still allows you to carve that part of their code and re-use it).
For example (but Henri seems to got fed up with Embarcadero and abandoned his Delphi projects) http://code.google.com/p/delphionrails/w/list
For another example there is http://blog.synopse.info/tag/HTTP
This implementation relies upon Windows http.sys driver, that was developed as a fast HTTP protocol implementation for Microsoft IIS.
During recent DataSnap performance shootouts mORMot-based server, working through http.sys AFAIR, shown great performance with low overhead.
BTW, Indy-based DataSnap was shown to only surviving of low to medium load.
Add an IdHTTPServer to the project.

How to use SocketRocket with socket.io?

The new iOS websocket library, SocketRocket, looks really awesome, and the chat example project is really sweet. The example chat server is written in Python, of which I know none. I'm slightly familiar with socket.io on node.js and prefer to try javascript. I tried connecting the SocketRocket TestChat simulator app to the node.js(6.10) socket.io(0.8.7) but the connection was refused. (Also, I'm not a node expert either, so this may be a silly question).
In a recent answer to an SO question, mikelikespie said to op: "I suggest updating your stack to use the iOS WebSocket library we just released."
What does that mean exactly? What is necessary to get the SocketRocket library to talk to a node socket.io server? Any sample code or suggestions are greatly appreciated.
Well you socket.io has it's own protocol built on transport protocols such as websockets, or long polling, well SocketRocket is just a websocket library, no more. Socket.io also has some authentication, so it's not possible to use it, with normal web sockets. What I suggest you to use is a just websocket server, no more than that. Such as ws, which should compatible. There are other libraries, but, ws I believe is actively developed at the moment, and newer than others.
You can also make your clientside socket.io compatible, but I think its uneeded. Here's the specs for it: https://github.com/LearnBoost/socket.io-spec
Hope I helped.
socket.IO-objc on GitHub looks to be a mature Socket.IO / Objective C Library
It uses SocketRocket to handle the websocket connections.
This will allow you to have a socket server that supports older browsers (degrades to long-polling etc.) and is still accessable to your iOS app via SocketRocket.
I have just implemented an active socket connection between a Node.JS server, and an iOS application, using this library. I used this one because the README on Socket.IO-ObjC says
The current version of this library does not yet support socket.io v1.0.
So if you want to use socket.io-objc, please fall back to v0.9.x.
but I always want to use the latest version for everything. So if you want to use Socket.IO v1.0, you can use the one on the link provided few line above.

Is there a way to allow Delphi applications to use Hazelcast?

Is there any way for a Delphi application to use the distributed cache from Hazelcast?
Hazelcast support memcache protocol. You can use a Delphi memcache client library to access Hazelcast cluster.
It depends - a small Java bridge service, using a simple object serialization (JSON) or a efficient custom serialization, would surely work. It could be implemented as a server with Grizzly, Netty or similar libraries. For a protoype, you could use a simple Java based HTTP server which the Delphi client connects to.
If you are not bound to use Hazelcast, there is a Delphi client library for memcached. See MemCached client with Delphi

Wiki: Current state of the art of Delphi 3rd party TCP/IP components libraries

I've not been doing bare metal TCP/IP for about 18 months, so I wonder what the current state of the art is.
I'm looking for both positive and negative aspects, with development of both server and client software.
I will be doing a project that needs a rock-solid TCP/IP layer, so for me that is an important aspect :)
For this to become a community wiki, I'm looking for broader answers than just 'rock solid'. So for instance information about the feature-width is also appreciated.
I'll be updating the question with relevant aspects found in the answers in order to get a wiki entry that has a balanced overview of those libraries.
For example, see my answer below with my past experience with Indy
I'm ambivalent on the exception handling and anti-freeze in Indy, though I got used to it, it still felt somewhat unnatural.
Right now I develop in both Delphi 2007 (non Unicode) and XE (Unicode), so the libraries I'm considering should support at least those two Delphi versions.
Edit: Summary of my past experience with Indy, and the comments (thanks Eugene, Marjan)
(please update with the current Indy state of the art):
Pro:
ships with Delphi
mature
development community
open source so lots of eyes scrutinizing those sources
a truckload of valuable comment documentation in the source code
OpenSSL support
supports a broad set of Delphi versions (including 2007 and XE)
wide choice of protocols
Con:
the version shipping with Delphi was not always the most stable one; download from the sources was usually required to get a stable build
(in the mean time) lots of duplication of code that now is in Delphi (but Indy requires for compatibility with older Delphi versions)
not all TCP/IP components were up-to-date (for instance, back then the POP3 client component did not support some basic POP3 commands)
version interoperability was a pain: upgrading from one Indy version to another could be very time consuming
I'm ambivalent on the exception handling and anti-freeze in Indy, though I got used to it, it still felt somewhat unnatural.
breaking changes are made between build updates; ifdefs required to accommodate those
Unclear release status if any at all, no RCs for a long while, getting trunk can make your local copy unstable
ICS - The Internet Component Suite
ICS - see www.overbyte.be. Open source by François Piette. To me this has always been the number 1 alternative to Indy. It's most interesting selling point: it makes using asynchronous stuff easy, and being async seems to be closer to "bare metal" sockets programming.
I've used it to build a fairly complex VNC proxy where the proxy itself (server) is built with ICS and the clients are a mixture of Indy and ICS. In periods of high demand the proxy handles about 100 simultaneous connections and about 10 simultaneous VNC screen sessions. It eats up an average of 5 mbit/s, handles connections over two distinct Internet connections. I don't think the 100 + 10 is the limit, because the server handles that without any problems and CPU usage is too low to mention.
Pros:
Works asynchronously
Somewhat easier on beginners because it doesn't need threads
Supports a good number of protocols
Cons:
Relies on Windows messaging. I'm simply not comfortable with that.
The async behavior makes implementing most protocols slightly difficult (because most protocols are in the form of send command / receive response). This shouldn't matter for most people since ICS offers ready-made implementation for the most-used protocols.
All that being said, I haven't used ICS in a very long time, I'm not up-to-date with all the bells and whistles. This is CW, so please edit and expand!
I have used Indy since 2003 for my own TCP communications framework. It is rock-solid, I have a version used with Delphi 2007 and another with Delphi 2010, if you handle the threadng correctly there is no need to use the anti-freeze stuff, and I have consistent exception handling on the client and the server by implementing my own wrapper around this.
You can dowload it here (http://www.csinnovations.com/framework_delphi.htm) - look for the Tcp units, mainly AppTcpServerUnt and AppTcpClientUnt.
I would strongly recommend Clever Internet Suite, it's by far the best designed and written set of communication components. It's not free and so not that well known, but it's well worth investigating.
Pro:
well designed and written
contains many components and implements various protocols.
supports a broad set of Delphi versions (including 2007 and XE)
SSL support
mature product as the release history indicates
Con:
not open source
You could consider using a higher protocol level like HTTP, because:
It's more firewall and VPN friendly;
It's well documented and known as a good protocol;
It already has secured HTTPS version;
It has a very low overhead over row TCP/IP;
It's ready to use in an AJAX environment (if you need it in the future);
Microsoft already did the low-level tuning for you in modern version of Windows.
In this case, you could take a look at two Open Source classes working from Delphi 6 up to XE:
THttpApiServer which implements a HTTP server using fast http.sys kernel-mode server:
The HTTP Server API enables applications to communicate over HTTP without
using Microsoft Internet Information Server (IIS). Applications can register
to receive HTTP requests for particular URLs, receive HTTP requests, and send
HTTP responses. The HTTP Server API includes SSL support so that applications
can exchange data over secure HTTP connections without IIS. It is also
designed to work with I/O completion ports.
The HTTP Server API is supported on Windows Server 2003 operating systems
and on Windows XP with Service Pack 2 (SP2). Be aware that Microsoft IIS 5
running on Windows XP with SP2 is not able to share port 80 with other HTTP
applications running simultaneously.
TWinHTTP which handles client-side HTTP/1.1 request using the WinHTTP API:
Microsoft Windows HTTP Services (WinHTTP) is targeted at middle-tier and
back-end server applications that require access to an HTTP client stack;
Is much faster than older WinINet API.
Resulting speed is very good (especially the server), and you will rely on Microsoft implementation. The first is the core of IIS, and the second is used in the latest versions of Internet Explorer.
The answer really depends on many factors and your requirements, such as
what layers are needed (TCP, SSL/TLS, application-level protocols)
whether you need a client or a server as well (server is much more complicated task)
whether you count paid options.
In general, not much (positive) happened in 18 months or even in 3 years as most developers look at .NET as primary development platform.
Clever Internet Suite mentioned in other answer and DevArt's SecureBridge gained some new functionality.
Our SecureBlackbox offers support for the most advanced features (besides native SSL/TLS): IPv6, HTTPS Proxy with basic, digest and NTLM authentication (starting with SecureBlackbox 9), International Domain Names (starting with SecureBlackbox 9), DNSSEC, bandwidth control and more.
Application-level protocols supported by SecureBlackbox are HTTP (client and server), WebDAV (client and server), FTP (client and server), SSH and SFTP (client and server), SMTP and POP3 clients, DNS client, AS2 and AS3. All of the protocols (besides SSH and SFTP, of course) have complete support for SSL/TLS.
The list of supported protocols can be found on Packages page. Supported protocol features are listed on Technical Specification page for each package.
Worked with NetMaster components way (way!) back in the old Delphi versions (2! 3! 4!)
Did some work with Indy, but had the unnatural feeling also (actually I'd describe it more as bulky)
Stumbled upon Synapse when I was searching for just a light wrapper around the Windows network API,
And then rediscovered plain old TTcpClient/TTcpServer. They are Delphi's own wrapper around winsock! I use them blocking, with a dedicated TThread inheritant for each TTcpClient, and let TTcpServer do the threads and do all the work in DoAccept, see here for an example.
This, fow now, gave me the rock-solid feel we're looking for. If you want to support heavy load, I would try and build a thread manager that handles several sockets/connections per thread, or have two sets of threads: a few that listen a larger number of 'dormant' connections, and the others that handle lesser 'active' connections, switching connections between the threads depending on wether a request or response is being handled. (e.g. HTTP's Connection: keep-alive)

Delphi Using Indy 10

I'm using Delphi 4, and I want to create a standard non blocking socket with out the clutter of Indy code (Pv4 and Pv6). and i want to get the computers IP address and be able to ping has any one done this. Can I do it with Indy 10 or Indy 9. And has any one made code up to do any of these things and tested it please.
Indy officially stopped supporting Delphi 4 a long time ago. Delphi 5 is the earliest version still supported. Delphi has its own socket classes - TClientSocket and TServerSocket - which can operate in both blocking and non-blocking modes. Indy operates strictly in blocking mode only.
Without using Indy, you can get the machine's IP(s) using either the WinSock API's gethostname and gethostbyname functions, or the Win32 API's GetAdapterAddresses or related functions, and use the Win32 API IcmpSendEcho function to ping.

Resources