like this?
Yes, you could do it like this.
But I have been thinking and want you to do it another way.
When you manipulate the length of an array within a loop that checks that array you can better use a while loop. Something like this:
var
I: Integer;
begin
I := 0;
while I <= High(Array) do
begin
// check messages for I
// do that here
// if Error remove item from array
if LastError <> 0 then
begin
Continue; // we don't need to increment so directory continue the loop
end;
Inc(I);
end;
This is because when you remove I from the array, and you move everything up one, you still need to check I again because you just moved everything up. You can do this in a while loop by using continue. It will go back in the loop without incrementing I.
so now if i open 1 server and 2 clients, the client 1 can get message from server but not from client 2 and client 2 can not get message from 1.
to recieve the message from client, should i make array of tcp in client program as well?
At the moment you can only communicate from server to client and back. You can't communicate between clients (I asked you and you said only communication from client to server was needed).
If you want to communicate between clients you could do that two ways.
One: You could establish a direct connection between clients. But you probably don't know the IPs of the client. Also, if you want to do that you need to open up a port on the router if the clients are on the world wide internet. I don't think you wanted to do that for the clients, do you?
Two: You already should open up the port on your router to your server if you want a client on the internet to connect to your server. But after that the server could relay messages from client to client. For example if the client sends a message "for client2: Hello client 2", you could check the beginning of a string on the server and if it says "for client2:" you send that message to client 2 on behalf of client1.
That way you are the only one who needs to change something in your router (port forwarding) and all the clients don't have to do anything.