polling only on socket, or can there be a trigger?
Dr. Hawkins
dochawk at gmail.com
Sat May 9 13:05:40 EDT 2015
On Fri, May 8, 2015 at 9:37 PM, Phil Davis <revdev at pdslabs.net> wrote:
>
> There are two basic approaches you can take, which you probably know but
> I'll lay them out for clarity. And maybe you're already doing one of them -
> from what you've told us, I couldn't tell.
>
>
What I have working is similar to the second one, but it doesn't solve my
problem.
I need a server sitting there, accepting connections from numerous
machines, which keeps the socket open indefinitely after the initial
connection. Everything I can find is basically "one-shot" or blocking.
My sequence is that the client connects to the server, and then sends it
periodic messages. On the initial connection, the server creates a
database connection and leaves it open (opening a database takes time
measured in hundreds of milliseconds). The approach of opening and
closing a database on each transaction simply isn't a realistic option for
me.
My application has an in-memory sqlite database, and watches for user
inactivity to synchronize. If I can get this working, it would let the
synchronizations become asynchronous (client writes and moves on, and later
gets a message of a write back and handles it).
At the moment, though, this only seems to be possible if I keep polling by
a loop that reads, and acts if the read isn't empty. I certainly *could*
have this work with round robin polling of all connected clients, but I
think this is going to chew processor cycles, which will cause grief on a
shared server initially, and require extra servers in the long run.
Although I strongly prefer postgres for a number of security and liability
reasons, livecode hasn't seen fit to write the couple of lines of code to
allow connection to a secure ssl socket for postgres, restricting it to
mysql. That means that to use postgres, I need to either run over a vpn,
or encrypt the data and have an application running at the other end.
--
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
More information about the use-livecode
mailing list