Solved

TServerSocket

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

12 Experts available now in Live!

Get 1:1 Help Now