> Since the UDPCLient is blocking when sending a message and it waits
> for 1 message, and not many, I have added the UDPServer just to use
> the listening thread that it implements.
Why not just have the UDPServer read everything? You don't really need the
UDPClient, you can send out data using TIdUDPServer as well, just send using
the Binding that you want to receive a reply with. In your OnUDPRead event,
look at the packet data and act accordingly.
> However this brings a problems, if I open more than client in the same
> computer it causes an error, probably because the PORT that I choose
> is in user already (idUDPServer is set to 44444)
Correct. You cannot have multiple servers on the same machine listening
on the same port at the same time.
> How can I have a UDPClient with a listener thread?
Move the TIdUDPClient into its own thread, and let it block that thread on
reading. What is the problem?
> or a UDPServer that shares the same port?
> or my approach is all wrong, besides it works when only one client is
> running (that is 99,99% of the cases)
If you really need multiple clients on the same machine, you have to make
them listen on different ports. You could let the OS pick an available port
for you (set the Binding.Port to 0), or you can make the clients communicate
with each other to coordinate their port usage with each other. Either way,
you need separate ports, period.
Remy Lebeau (TeamB)