Quick guess - is the buffer getting overrun/full? Your boolean control is set to a "latching" mechanical action, so when you ask it to send a command, you are most likely send a LOT of commands (only a 5 ms wait in each loop).
Also, you might want to wire through the TCP reference to a shift register.