For a more sophisticated implementation you may want TCPServer and StreamRequestHandler, but i had some issues with disconnected sockets and to keep it simple (i.e. almost no error handling) i just switched to udp.
I did not manage to transfer a blinking bike rear light, i guess either the sensor or the led switching just isn't fast enough.