ASTA Vision


An Introduction to ASTA Sockets for Database Application Developers

 

ASTA was designed to be used by Delphi Database Application developers using skill sets they already possessed. ASTA uses tcp/ip for it's transport. Tcp/ip is a protocol that maintains state and was designed to be reliable. There are other protocols like HTTP, which is used for browsers, but is stateless. HTTP connects and disconnects to talk to remote hosts. Tcp/ip maintains it’s connected “state”.

 

Tcp/ip uses an IP Address and Port combined to uniquely identify a circuit. This connection is called a socket. ASTA provides an AstaServerSocket and AstaClientSocket to allow remote ASTA clients to communicate with ASTA Servers.

 

ASTA sockets are non-blocking and event driven so they are very responsive and scale well. Threads are used in ASTA database access on the server in one of 3 ASTA threading models as well as optionally in ASTA Messaging. One of ASTA design goals was “To do all threading internally so that Developers need not be concerned with threading issues” so all ASTA threading abilities are implemented internally by ASTA components so that the developer doesn’t really have to know anything about threads except to choose which way you want ASTA Servers to run.

 

AstaServerSocket

 

An ASTAServer consists of an AstaServerSocket that is connected at a given IPAdress and Port. Only one ASTA server can run on a that IPAdress and port. If you attempt to start up another instance of an AstaServer on the same IPAddress and Port you will receive an error. An AstaServerSocket, when started, will listen for remote ASTAClientSockets and attempt to accept a connection from them. ASTA has a number of ways to provide security for your application.

 

The AstaServerSocket has events and properties that abstract the Database process and  allow for any Delphi 3rd Party Database Components to be used in an AstaServer. Currently there are 20 Delphi 3rd Party Database components supported by ASTA.

 

AstaClientsocket

 

ASTA client applications must use a TAstaClientSocket to communicate with remote ASTA Servers. The AstaClientSocket has IPAddress and Port properties that must be set to the same of the AstaServer that it intends to connect to. The host property can be used instead of the IPAddress.

 

To facilitate communication an AstaServerSocket must be started at an IPAddress and port and an AstaClientSocket must be able to connect to that AstaServerSocket via tcp/ip.

 

ASTA uses non-blocking event driven sockets as it's underlying transport. These Sockets are by their nature asynchronous. This means that a message sent by one method does not wait for any response from a server and if a response does come it will fire an event. This is similar to Windows messaging where you send a message to a Window component and receive a message back in an event.

 

This means that by you cannot write procedure code using non-blocking event driven sockets. To be able to write code that you are used to write in normal Database Applications like

 

            AstaclientDataSet1.Open;

            While Not AstaClientDataSet1.Eof do begin

               //do something

               AstaClientDataSet.Next;

            End;

 

ASTA had to implement something called AstaSmartWait to allow Database Application Developers to write procedural code. When you initiate any Database calls from AstaClientDataSets ASTASmartWait will eat windows messages while waiting for a response from the server to allow you to write procedural code.

 

This also means that you cannot communicate with a Remote ASTA server until after an AstaclientSocket has connected to the server. You cannot write code in the FormCreate to open a TAstaClientSocket and then open a TAstaClientDataSet. This will not work

 

            AstaClientSocket1.Active:=True;//async call

            AstaClientDataSet1.Open;//socket has not connected to the server yet

 

The earliest you can communicate with an ASTA server or open a TAstaClientDataSet to fetch data from a remote server is in the OnConnect Method of the TAstaClientSocket.

 

When AstaclientDataSets are open at design time they actually are opened on 2 occasions. The first time is in the formcreate before the TAstaClientSocket is connected to the server. ASTA internally will note all the AstaClientDataSets open at design time and add them to an internal list so that after the TAstaClientSocket is connected, the DataSets can be reopened again, and this time they will fetch data from the remote server.

 

The asynchronous nature of sockets, and knowing when you can open AstaClientDataSets are important concepts and techniques and the faster you understand the relationship of your remote application and it’s ability to communicate with an ASTA Server, the easier it will be with you to be productive. Depending on your connection, whether on a LAN or over a slow dial up Internet account, the socket performance may vary wildly but once you get the basics of the way things flow you will find that you can write robust and brisk ASTA client applications


 

ASTA in 60 Seconds | Products & Training | Developer Details | Free Internet Tools
Demos | Support & Manuals | Business Views | ASTA Vision | Tutorial Central
News | Contact Us | Testimonials | ASTA Links | Partners

Copyright © 2000, ASTA Technology Group.