Client Server Database Access the xBase Way

Postby xProgrammer » Sun Aug 24, 2008 12:28 pm

Hi Patrick

Thanks for your interest. I don't profess to know that much about letoDB - indeed I really only became aware of this when Antonio responded to my first posting in this thread. I did look at it briefly and my impression was

1. that it was written in C and therefore much harder for me to understand / modify whatever, whereas I felt I could do it all in (x)Harbour - and now have pretty much proved that.

2. that it passed data by position which I don't like and didn't fit as well into my architecture as I would have liked. Getting back an array which can be used to update all data properties of a class in a single call is pretty magical!

I use FiveLinux because of the level of support that Antonio provides - I wouldn't expect the same of letoDB. Just getting letoDB working and modifying it to suit me would probably take more time than writing what I have.

I may well be misguided in the above judgments, but that is why I have done what I have done.

I also want to be able to run the application in a local mode. I should be able to simply set a flag so that the communication via sockets is disabled and both components are handled by the one executable. (Of course you could always have both client and server on the one machine but why not just enable stitching them together.)

One side benefit of what I have done is it has provided the trigger for developing generic code for doing data lookups in various ways. And of course this way the data layer is much more OO style than is possible with anything based on SQL.

Regards
Doug
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby Patrick Mast » Sun Aug 24, 2008 12:44 pm

Hey Doug,

Ok! It's good to see this being done in pure [x]Harbour code yes. So, please go ahead and show us all what [x]Harbour is capable of doing.

Graet job!

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby xProgrammer » Sun Aug 24, 2008 12:58 pm

Hi Patrick

Thanks for your comments. I have found this to be quite an exciting project. I just wish I could work on it full-time. But the progress has been very pleasing. Across my VPN I am seeing something like a 30 fold speed increase for queries involving fairly sizable lists. The code has been basically "functional" for a few days now but I keep adding little features and I need to do more on error handling, retries etc. And I have been restructuring it so its easier to support many different queries and queries of different types. I do have to add support for inserts - but that's really only a matter of porting my primary key allocation code as I am already handling updates just fine. All without a single line of C. I have found xHarbour to be a great development environment.

Regards
Doug
xProgrammer
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Re: Client Server Database Access the xBase Way

Postby codemaker » Mon Apr 27, 2009 8:05 pm

First of all, many regards to all old friends!
I "know" many of you since the FW version 1.92
I'we been too bussy and didn't visit forums much... Such is life.
But, it's nice to "see" old faces here again :)
I hope you're all up and running :)

Now, about some interesting issue Doug started:
(I spoted this issue today and am sorry I didn't find it eralier..)

Hello Doug,

A very interesting work.
It does almost exactly what I am doing for years by now. And I have no time to make it more widely usefull in all my later apps. But what I have done 5 years ago works up to now perfectly. And all written in xHArbour/Fivewin (Server) and xHArbour/Fivewin on client side. It is a part of one of my apps - a Payroll software.
We should really expand this kind of functionality
Using Sockets.

Let me explain.

1. We have clients which pays us every year the certain license fee. Each client has his data written in a Hardware dongle, the identification data is a number ID.

2. On our company server, we have a complete database system which we use to control the clients (add a new, change the data for the existing clients, change the number of Employees allowed for each, change the licenses expiration dates and many other elements...
Also on the server, the xHarbour/Fivewin program is running all the time 24/7, listening to defined port. The small dialog shows the status and if administrator wants to check, he can see messages about who is connecting and when. Also we have a log system which is writen into DBF on server, we review later.

3. The client has a menu option where they can for example "Update their license".
The clients program take the data from a Dongle, construct the string which contains all necessary data and send it automaticaly through the defined port, to the company server, wehere we have a xHarbour program listening on the same port number. There we can define the license expiration date and some other data for exact client.

4. When the request come to the defined port on the server side, the server side program check the string and check the validity of the client ID (does it exists at all). Then it checks into the databases the validity of the request (is client active for example) and then takes the license expiration date from the DBF, among some other data. Send it back to the Client.
If the client paid for his license update, the server program also extends the expiration date to the given period (1 year in our case) If the cient didn't paid for his update, the apropriate message is sent back to them.
At the same the log is appended to the DBF and we can later see who and when tconnected, also seen unsuccessfull logs etc..

5. The client program reads what came from server and if there is no error and all data valid, the new expiration date is written into the DOngle and from then on the client has updated his license automaticaly.

This is simplified scenario.
After all these years I decided to rewrite our WebPayrol application to use this kind of logic and have client nicely work in a perfect Fivewin environment (with all whistless and bells) at the same time connection to the server will be done per request where the server program will maintain the data and send them back to the client....
Much nicer than any WEB aplication...

There is much we can do using socket, indeed... Doug is absolutelly right. This way I can avoid having SQL of any kind and no additional programs (servers) installed.
We have a few hundred clients which contact our server very often from all parts of USA and we never had any problem because of their concurent accesing the server program

Regards
Boris
Belgrade, Serbia
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: Client Server Database Access the xBase Way

Postby xProgrammer » Tue Apr 28, 2009 12:07 pm

Hello Boris

Greetings from Australia. Very pleased to read your comments. Code has been working reliably for me for many months now. My server and clients are all Linux but recently I needed to be able to access some data generated and stored on a Windows PC and I could use almost exactly the same code recompiled for Windows.

To date I have avoided using threads. I only have a need for 10 clients at present so I have 10 copies of the server software running each listening on a separate port. Not the most elegant solution but it got me up running fast and has been 100 per cent reliable. Expanding functionality of my software has taken precedence over learning to write threaded code.

If people are interested I am happy to share what I have learned to date.

Regards

Doug (xProgrammer)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Re: Client Server Database Access the xBase Way

Postby codemaker » Tue Apr 28, 2009 3:27 pm

Hi Doug,

Just a question, why are you using 10 separate EXEs listening to a different ports?
Any specific reason for that?

I have only one EXE running on server, listening to one port.
All clients (a few hundreds) send requests to this one port. All these years we didn't encounter any problem with such approach.
All clients have different ID which is transfered to this server EXE (among a bunch of other data) and the EXE properly opens the needed data to allow client to expand their license key...

One thing I have to check.
The time which passes after the client issues the request for license extension.
After they do this, the prorgam opens the connection to some IP address and to a specific port.
Then, the EXE on server does the job very fast and returns the needed information back.
This time is not a "lighten" speed and I am not sure how will this reflect to a WEB application which I intend to design, using the port aproach this time (instead a regular HTTP requests, as it works now)
Each license updating process lasts about 10-15 seconds which seams to be unacceptable for WEB aplication to change data, I am affraid...
I realised that the most of this time is spent on connection to server through the gioven port number...
I don't know if this connection time can be shortened somehow..

Regards
Boris
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: Client Server Database Access the xBase Way

Postby xProgrammer » Tue Apr 28, 2009 9:32 pm

Hi Boris

Yes, I am currently running 10 copies of my executable on the server each listening on a different port. I know its not very elegant and is not extremely scalable but I wanted to get up and running and it works. Threaded code would be the answer and indeed the code is designed to go threaded but I haven't had the time to learn how to write threaded code and test it for reliability. The response time is excellent, miniscule on the server, the only delay being on the client end ensuring that the servers response has been received completely. That is set to around 0.5 seconds which isn't an issue. (there may well be a more elegant and efficient solutoin here too - currently looping with a timeout) The reason for multiple copies of the server code is that I wanted to be certain that there was no problem with two clients making a request of the server simultaneously. Having said that whilst testing in development stage I didn't actually simulate a problem with two clients accessing a single server code. Hopefully one day I will get the time to play with threaded code and write a better server. My server has no GUI, it just outputs text to the console and is OS agnostic - ie the same code runs under Linux and Windows. To compile under Windows I just have to change the source to have CR-LF's.

When I get a chance I'll put up some of my code and maybe we and others can discuss improving and / or generalising it.

Regards

Doug (xProgrammer)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Many Other Applications Possible

Postby xProgrammer » Wed Apr 29, 2009 9:12 am

Hi all

I just thought I should add that this technique can be used for many different purposes other than just database access. Pretty much anytime you want a process performed on another computer (or the same computer for that matter) with (optionally) information returned to the originating computer. And it can be between different operating systems.

xProgrammer
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Re: Client Server Database Access the xBase Way

Postby Carles » Thu Apr 30, 2009 6:18 am

Hi Doug
If people are interested I am happy to share what I have learned to date.


I am very interested in this thread. I find interesting and i would like to learn on the topic. Can you send me some funtional example of connection and the way of processing the petitions? Some contact email to speak ?

Regards.
C.
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1134
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Client Server Database Access the xBase Way

Postby xProgrammer » Mon May 11, 2009 1:12 pm

Hi Carles

I have meant to post a reply here for many days now but have been very busy with upgrades, visitors etc. I want to reuse this technique for another project and will post here shortly, probably in a new thread. Sorry its taking so long but I want to review and possibly neaten up my code.

Regards
Doug
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 55 guests