Important Procedures for an Internet Access Control Application
(Page 1 of 5 )
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.
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);
var
str,cmdrslt,cmd,placeholder:string;
begin
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
begin
The function takes the current time:
Con:=Now;
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:
IP :=Connection.Socket.Binding.PeerIP;
Next: Taking Names >>
More Delphi-Kylix Articles
More By David Web