Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Mar : Re: UDP sends arbitrary port

www.cryer.info
Managed Newsgroup Archive

Re: UDP sends arbitrary port

Subject:Re: UDP sends arbitrary port
Posted by:"Craig" (cra..@radicalage.com)
Date:Wed, 29 Mar 2006 15:17:23

Thank you for the speedy response!

Regarding "Delphi Internet", I am referring to the UDPSocket component that
installed when I installed Delphi that resides under the "Internet" tab.
Sorry I didn't make that more clear.

I cannot see how to bind the ports using that component.  I took a look at
the exposed methods/properties of TBaseSocket and binding is not an option.
The component has the localPort, remotePort properties, but setting them has
no effect.
Perhaps there is a way to bind after setting those properties, but I don't
see how.

Regarding the Indy UDP client:
I have attempted what you suggested, but still the source port is arbitrary.
Essentially, I just want to source and destination ports to be the same.

            idUdpC.Binding.Port := 1020;
            idUdpC.Binding.Bind;

results in the destination port being any number other than 1020.
            idUdpC.Binding.PeerPort fails as it is a read only property.

Thanks again,
Craig


"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:442afa46$1@newsgroups.borland.com...
>
> "Craig" <craig@radicalage.com> wrote in message
> news:442ae4c9$1@newsgroups.borland.com...
>
>> Is there any way I can assign the local port when sending a UDP packet?
>
> Like any other socket, a UDP socket can be bound to a local IP and a local
> Port using the socket API bind() function before read/writing data.
>
> In Indy, TIdUDPBase has a Binding property of type TIdSocketHandle, which
> has its own IP/Port properties and a Bind() method.  You would have to
> call
> Bind() before sending your data.
>
> As for "Delphi Internet", how you bind a socket depends on the specific
> component(s) that you are actually using.
>
>
> Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive