Solved

TServerSocket

Posted on 2001-08-28
3
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

617 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