Re: Ports

I am using Kylix C for this console application, but I am trying to keep it

> simple since this has to go > in a smaller embedded thing. So I use, "socket", "connect" and "send" to get > it out and it is correctly received at the desired port no. (at present set > to 5001) I can also see that the source port no. is different - 1025 and I > don't think it should be that. Now comes the real annoyance. When I send a > message back to the Linux PC it listens at port 1025 and not 5001 as I want > it to do. I have tried both "recv" and "recvfrom" to receive the message.

That's the way it usually works. The client connects from a unknown random port above 1024, to the specific server port (i.e. 5001). the server then sends the data back the same channel from the known port (5001) to the unknown port (1025).

You can change the client to always use a known port to start with if you want by using the bind() call, but usually the first way works fine.

regards

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Damion de Soto - Software Engineer  email:     damion@snapgear.com
SnapGear ---                           ph:         +61 7 3435 2809
  | Custom Embedded Solutions          fax:         +61 7 3891 3630
  | and Security Appliances            web: http://www.snapgear.com~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ---  Free Embedded Linux Distro at   http://www.snapgear.org  ---
Reply to
Damion de Soto
Loading thread data ...

Hi,

I found this link telling with examples exactly what to do:

formatting link

Thanks,

Jens.

server

from the

want by

Reply to
Jens Munk

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.