Thanks.
TIdPeerThread(List.Items[Count]).Connection.WriteLn('displaystring');//write
the command to the client
TIdPeerThread(List.Items[Count]).Connection.WriteLn('This is
a test string bla bla');
end;
finally
tcpserver.threads.UnlockList;
end;
of course you will have to have a thread on the client that listens for
incoming commands
Note that if the user is behind a proxy or NAT router the peer IP will be
that of the router.
You should be sending the clients IP when they connect and storing it in the
data property of the connection, then you can do stuff like compare the
actual IP to the peer IP and determin if they are behind a router, if they
are the IPs will be different.
Tony Caduto
"TheBigBadWolf" <thebig...@gmx.at> wrote in message
news:3d5cbda8@dnews...
> and how can i get all the ip addresses of the clients?
> thanx
>
>
> "Tony Caduto" <tony....@micorp.com> schrieb im Newsbeitrag
> news:3d5be31d@dnews...
Just write a function that returns a tstringlist and when you loop through
add the ips to the list, piece of cake :-)
for Count := 0 to List.Count -1 do
begin
TIdPeerThread(List.Items[Count]).Connection.WriteLn('displaystring');//write
the command to the client
TIdPeerThread(List.Items[Count]).Connection.WriteLn('This is a test string
bla bla');
theIP:=
TIdIOHandlerSocket(TIdPeerThread(List.Items[Count]).Connection.IOHandler).Bi
nding.peerip;
end;
"Tony Caduto" <tony....@micorp.com> wrote in message
news:3d5be31d@dnews...
> What if I wanted to send a mesage to all the clients when the server
> exited abnormally (i.e. Ctrl + Alt + Delete)
>
> Where would this code go. I want to kill all existing clients when the
> server crashes.
That code would go in the client ;-)
If you simply kill the server it won't execute a single more instruction,
so it can't let the clients know.
Therefore, you have to have an "alive-check" in your clients.
johannes
> Therefore, you have to have an "alive-check" in your clients.
I don't think. If the server somehow dies, Windows (NT of course) almost
always frees all its handles. On the client side, you will get a
disconnect at this point.
However, this is not true if someone unplugs the network cable or some
router facility on the way fails.
-Michael