Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Jan : Help with socket ports on TUDPSocket

www.cryer.info
Managed Newsgroup Archive

Help with socket ports on TUDPSocket

Subject:Help with socket ports on TUDPSocket
Posted by:"PC Pete" (pcpe..@audiography.com.au)
Date:Fri, 11 Jan 2008 14:38:47

I'm porting a very simple network application from D6 into Turbo Delphi.
It all seems to work OK, except for a problem I'm having setting socket
listening ports.
Instead of the old TNMUDP component, I've tried to use the TUDPSocket as
the replacement. Apart from some method names, it seems to provide
similar functionality.
But although I explicitly set remote IP and port, and local port
numbers, when I call SendBuf, each packets' sourceport is not the local
port I specified.

The code (so far) looks like this:
  MySocket.RemoteIP := '192.168.0.6';
  MySocket.RemotePort := '2424';
  MySocket.LocalPort := '2424';
  MySocket.Active := True;
  MySocket.SendBuf(Buff, Blen);
.... and at this point, the packet is sent, with a random source port
number - anything _except_ the one I specified, i.e. 2424.

The same code sequence in the "old" application is identical, and the
packet that goes on the wire contains the correct source and destination
ports.

I've tried defining an OnSend handler just to see if something is
changing somewhere in the send routine, but although the component's
LocalPort property is set correctly, it doesn't correspond with the
packet that actually gets sent.

Can anyone help to explain what I'm overlooking?

I'm a bit of a novice when it comes to using TCP/UDP components,
although I have a reasonably good grasp of networking (protocols, packet
  fields, etc). But this doesn't make sense.

Thanks for any ideas...
PCPete

Replies:

www.cryer.info
Managed Newsgroup Archive