Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Nov : Re: Multiple bindings with TidUDPServer doesn't work?

www.cryer.info
Managed Newsgroup Archive

Re: Multiple bindings with TidUDPServer doesn't work?

Subject:Re: Multiple bindings with TidUDPServer doesn't work?
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Thu, 8 Nov 2007 18:01:55

"mike" <johnson40@zonnet.nl> wrote in message
news:4733a91e$1@newsgroups.borland.com...

> I am trying to start an indy udpserver which listens to multiple ports.

You did not say which version of Indy you are using.  You appear to be using
Indy 10, which which release of it exactly?  At one point, the threading
model for TIdDUPServer was changed in Indy 10 from using a single thread to
manage all Bindings to using multiple threads, one for each Binding
individually.

> I have tried to set multiple bindings designtime and runtime, but in
> both cases the onudpread event only seems to fire when all possible
> ports have been written to by the clients.

That is not how it works.

> What I am trying to achieve is that the onudpread fires whenever
> a client writes somthing to one of the listen ports.

That is exactly what it already does.

> In the following code sample, I press the "write to port 1000" button
> and the onudpread fires as expected, but when I press it the second
> time nothing happens.

Is ShowMessage() still active at the time of the second press?

> Only if I press "write to port 1001" onudpread mysteriously fires
> twice, once for the 1001 port write and only then the "cached"
> 1000 port write suddenly emerges? Is this an Indy bug, or am
> I missing something?

For that to happen, the OS would have to be reporting that the first socket
is not readable until after the second socket has become readable.  That is
not standard socket behavior, so something else has to be happening to block
the first socket.

> procedure TForm64.IdUDPServer1UDPRead(Sender: TObject; AData:
> TBytes;ABinding: TIdSocketHandle);
> begin
>  showmessage('received on port: ' + inttostr(ABinding.port));
> end;

ShowMessage() is not thread-safe.  Use MessageBox() from the Windows unit
instead.


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive