Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 4 - Server Code for an Internet Access Control...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Server Code for an Internet Access Control Application
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-09-08

    Table of Contents:
  • Server Code for an Internet Access Control Application
  • Custom Procedures and Functions
  • Timing Procedure
  • Final Part of the Procedure

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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.

     

    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...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek