grini
asked on
TServerSocket
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?
How can I do it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
grini, use this example:
{ var global }
var
total: integer;
...
procedure TForm1.FormActivate(Sender : TObject);
begin
total:=0;
end;
procedure TForm1.ServerSocket1Client Connect(Se nder: 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.ServerSocket1Client Disconnect (Sender: TObject;
Socket: TCustomWinSocket);
begin
dec(total);
end;
Alexandre Santos
{ var global }
var
total: integer;
...
procedure TForm1.FormActivate(Sender
begin
total:=0;
end;
procedure TForm1.ServerSocket1Client
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.ServerSocket1Client
Socket: TCustomWinSocket);
begin
dec(total);
end;
Alexandre Santos
u can do that like this:
if (ServerSocket.Connection.C
Dennis