Solved

TServerSocket

Posted on 2001-08-28
3
263 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Virtuailstring tree compare node issue 14 125
Working with hours 3 64
tidtcpserver connection lost handle 2 100
Drag & Drop... Data from one grid to another 2 40
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

789 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