Solved

TServerSocket

Posted on 2001-08-28
3
259 Views
Last Modified: 2010-04-06
So, I have a serversocket and I want that no more than N(e.g. N=3) clients to be able to connect to this.
How can I do it?
0
Comment
Question by:grini
3 Comments
 
LVL 3

Accepted Solution

by:
Pegasus100397 earned 20 total points
ID: 6432437
Grini,

 In your OnConnect event, get the ServerSocket.Connection.Count and check to see if its over 3. If it is then issue a disconnect to the 4th socket.

Good luck with your project!
Pegasus
0
 
LVL 1

Expert Comment

by:Dennis9
ID: 6434049
Hi.
u can do that like this:
if (ServerSocket.Connection.Count = 3) or (ServerSocket.Connection.Count > 3) then ...//some code to not let more people in


Dennis
0
 
LVL 2

Expert Comment

by:alsantos
ID: 6434756
grini, use this example:

{ var global }
var
  total: integer;

...

procedure TForm1.FormActivate(Sender: TObject);
begin
total:=0;
end;

procedure TForm1.ServerSocket1ClientConnect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
inc(total);
if total > 3 then begin
  socket.Disconnect(total);
  socket.SendText('Error. 3 connections already active.');
 end
else begin
  socket.Accept(total);
  socket.SendText('Connected.');
end
end;

procedure TForm1.ServerSocket1ClientDisconnect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
dec(total);
end;


Alexandre Santos
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now