Home arrow Delphi-Kylix arrow Page 4 - Server Code for an Internet Access Control Application
DELPHI-KYLIX

Server Code for an Internet Access Control Application


In the preceding article we dealt with the functional requirements of the server application as well as with the components that make up the server interface. In this article we will continue to build on the concepts that we discussed there and at the same time explore the code that runs the server application.

Author Info:
By: David Web
Rating: 5 stars5 stars5 stars5 stars5 stars / 9
September 08, 2008
TABLE OF CONTENTS:
  1. · Server Code for an Internet Access Control Application
  2. · Custom Procedures and Functions
  3. · Timing Procedure
  4. · Final Part of the Procedure

print this article
SEARCH DEVARTICLES

Server Code for an Internet Access Control Application - Final Part of the Procedure
(Page 4 of 4 )


The final part of the procedure searches for the workstation on the context list and then sends the session information to that workstation:



List := form1.ts.Contexts.LockList;

try

for I := 0 to List.Count-1 do

begin

Context :=TMyContext(List[I]);

if Context.compname = theStation then

begin

try

Context.Connection.IOHandler.WriteLn('activate:'+theStation+'@'+thetime);

except

end;

Exit;

end;

end;

finally

form1.ts.Contexts.UnlockList;

end;

form1.memo1.Lines.add('error.');

end;

The "parsestring()" function is at its simplest a string handling function. It is responsible for parsing the strings that are sent between the server and client applications. This particular function will also be required by the client application according to the protocol requirements. Our custom protocol requires all communication to have the following format:


'activate:'+theStation+'@'+thetime


There are two delimiters, the colon(:) and the at(@) sign. Both of these are used to parse the communication into three parts. Below is the code that does the job. It is commented and easy to understand:

function ParseString(s : string; var Token1,Token2,Token3: string) :

boolean;

var

P1,P2 : integer;

begin

//store positions before and after the delimiters

P1 := Pos(':',s);

P2 := Pos('@',s);


//Test if both delimiters are present, in the right order and

//at least 1 char apart

if ((P1 > 0) and (P2 > 0) and (P2 > P1) and (Abs(P2-P1) > 1))

then begin

//store the different parts

Token1 := Copy(s,1,P1-1);

Token2 := Copy(s,P1+1,P2-P1-1);

Token3 := Copy(s,P2+1,Length(s)-P2);

Result := True; //valid string

end

else Result := False; //invalid string

end;


The parsestring() function is of the utmost importance to the overall communication between the server and the client. Without this function there will be a complete breakdown of communication. So it is very important that you understand how this function works and improve on it.

Conclusion

There are a lot more procedures in the server code that we will look at, but unfortunately we will not look at all of them. In the next article we will cover three more procedures that also play a prominent role in the functional requirement of the server application. If at any stage anything is unclear to you about the code, please do not hesitate to contact me.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
DELPHI-KYLIX ARTICLES

- Loading an XML Document into the DOM
- Delphi Wrapper Classes and XML
- Delphi and the DOM
- Delphi and XML
- Internet Access: Client Service
- Finishing the Client for an Internet Access ...
- The Client for an Internet Access Control Ap...
- User Management for an Internet Access Contr...
- Important Procedures for an Internet Access ...
- Server Code for an Internet Access Control A...
- Constructing the Interface for an Internet A...
- Building a Server Application for an Interne...
- Building an Internet Access Control Applicat...
- Client Dataset: Working with Data Packets an...
- Using the Client Dataset in an N-Tiered Appl...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials