Important Procedures for an Internet Access Control Application
In the preceding article we started to explore the code that makes up the server communication. If you havenít read that article, please make sure to do so, because almost everything that I will be discussing in this article will directly reference code that we discussed there. A lot of the things that we will be discussing here will make sense once you have read the previous article.
Important Procedures for an Internet Access Control Application (Page 1 of 5 )
The three procedures
There are three more procedures that we must look at before we conclude the server portion of this article, because they are also essential to the overall functionality of the server program. The first of the three procedures deals with what happens when a workstation registers with the server at startup:
procedure TForm1.tsConnect(AContext: TIdContext);
If you look back at the discussion that we had about the TIdContext class, and take a closer look at the constructor creation procedure, you will note that the properties and methods of the TidContext class were inherited by the TMyContext object. This means that we will be able to access all the properties of the context class through the TMyContext object by using the dot notation.
For example, to access the compname property of the object, we simply type TMyContext(AContext).compname.In other words, every client or workstation that connects will be given its own context in which their communication with the server will take place. It is also at this point that the context class sets up the context list that is updated as workstations connect to the server:
with TMyContext(AContext) do
The function takes the current time:
Then it checks to see if the client is connected by examining the socket property of the connection:
if (Connection.Socket <> nil) then
If the socket indicates that there is a client connected, then the client IP address is taken: