Go Down

Topic: Multiple sockets on W5100 shield (Read 2018 times) previous topic - next topic


How do you use sockets other than socket 0 on the W5100 since socket 0 is hard coded?


You can have a look at the Wiznet library as that one apparently uses all of the sockets.

Are you sure that you an only use socket 0 with the ethernet library? I don't use these myself, but I think I remember seeing some code to choose the first available socket in the W5100. :\
This... is a hobby.


I was referring to the UDP class in particular.
It looks like the author hard coded the class to be socket 0, see code from udp.c below.
I've managed to get it working by adding functions to udp that include the socket number.
I also needed to call functions in w5100 directly to set registers required for multicasting. I should really create functions in the udp class to set those registers.

/* Start UDP socket, listening at local port PORT */
void UdpClass::begin(uint16_t port) {
  _port = port;
  _sock = 0; //TODO: should not be hardcoded
  socket(_sock, SnMR::UDP, _port, 0);

Go Up