Socket implementation

I was checking the socket (in socket.c) implementation.

Are there any (hardware core) reasons that the socket function cannot dynamical allocate a socket number index?
Right now it looks it will use the sn passed in function parameters, but I was expecting it could choose any free socket index and return that id…


It’s possible.

uint8_t socket(port, flag)
  for( i < 0 ; i < MAX_SOCK_COUNT; i++)
     if(getSn_SR(i) == SOCK_CLOSED) break i;
  if(i > MAX_SOCK_COUNT) return -1;
  // omitted.
  return i;

Thank you.