FreeRTOS+TCP multi use and examples

claudiorossi wrote on Friday, August 31, 2018:

Hi Hein
if I understand, the socket process is tied to port number instead to IP address, then I need to create a socket for each port I intend to use.
For example, in my case I have 2 port: the first at IP 192.168.0.0 and the second at 192.168.1.0.
The first port is used for the connection of a telnet client (port 23) and a HTTP client (port 80), while the second port for a FTP client (port 21).
So I need to do the following:

  1. Create 2 network interface and 2 network node.
  2. Call FreeRTOS_IpStart function
  3. Create a socket set (FreeRTOS_CreateSocketSet).
  4. Create my 3 socket (for telnet, HTTP, FTP) and initialize them (_bind, _setsockopt, _listen)
  5. Add sockets with FreeRTOS_FD_SET().
  6. Create a process(loop) for socket acceptation for each of my sockets (FreeRTOS_accept)

If a connection is requested to a port then FreeRTOS_accept function return a socket structure pointer for this connection.
Is my procedure correct?

But if I connect the FTP client to port 0 (instead of port 1) and try to connect the client to 192.168.0.0:21, the FreeRtos_accept function will accept the connection?
If yes, if I want to know the IP address of my connection in order to distinguish the port (and eventually write an error message) can I use the address structure filled by FreeRTOS_accept function?

I hope I was clear in my exposition.
Thanks and best regards