Home arrow Delphi-Kylix arrow Finishing the Client for an Internet Access Control Application
DELPHI-KYLIX

Finishing the Client for an Internet Access Control Application


Last week we began our discussion of the client side of an Internet access control program. This week we'll continue to cover the important parts of the code. We'll start with the reading thread, then go to the ini file. Keep reading to be enlightened.

Author Info:
By: David Web
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
October 06, 2008
TABLE OF CONTENTS:
  1. · Finishing the Client for an Internet Access Control Application
  2. · Check the ini file
  3. · Code Explained
  4. · The Timer Window

print this article
SEARCH DEVARTICLES

Finishing the Client for an Internet Access Control Application
(Page 1 of 4 )

The reading thread listens for any communication from the server. It will wait for commands from the server for as long as the client is connected and then pass any communication on to the synchronization functions for processing. Here is the code:

constructor TReadingThread.Create(AConn: TIdTCPConnection);

begin

FConn := AConn;

inherited Create(False);

end;


procedure TReadingThread.Execute;


begin

while not Terminated and FConn.Connected do

begin

TLog.AddMsg(FConn.IOHandler.ReadLn);

end;

end;


//**********end message sync functions






procedure TForm1.btnExitClick(Sender: TObject);

begin

close;

end;

When the client is connected, the reading thread is activated and set up:


procedure TForm1.tcConnected(Sender: TObject);

begin

rt := TReadingThread.Create(tc);

end;


procedure TForm1.btnDisconClick(Sender: TObject);

begin

tc.Disconnect;

end;


One of the many actions that is carried out when the client connects is implemented here. First, the client sends over its name and IP address. The btnConnect procedure shows how it is done in code:

procedure TForm1.btnConnectClick(Sender: TObject);

begin

tc.Host:='127.0.0.1';

tc.Port:=1150;

with tc do

begin

try

Connect;

Socket.WriteLn(edname.text+':free@plchldr');

//Socket.WriteLn(GetComputername+':free@plchldr');

except on E : Exception do

showmessage('Could not connect to remote host. Check to see if you entered the right IP address');

end;

end;

end;


procedure TForm1.tcDisconnected(Sender: TObject);

begin

if rt <> nil then

begin

rt.Terminate;

rt.WaitFor;

FreeAndNil(rt);

end;

end;


procedure TForm1.oneClick(Sender: TObject);

var

mins:widestring;

begin

mins:='5'; {

form1.Visible:=false;

form2.times:=strtoint(mins);

form2.label1.caption:=mins;

form2.show; }

//wb.Navigate(path);

end;


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