The example TCP socket server on https://wiki.python.org/moin/TcpCommunication works just fine for me, except if the client stops sending data to the server, the server socket script stops running, so you can't restart the client without restarting the server.

I added a second while loop so that the server waits on "s.accept" to accept a new connection but that doesn't work. How kan i keep the server alive? (One connection at a time is sufficient, no need for multiple connections using threads)...

Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

It is that second socket that is closed when either the server or the client has done it's thing. Then one can loop around and call accept again.

In fact normally one should be prepared to accept multiple incoming connections, each on their own new socket, at the same time. But that gets us into talk of spinning up a new thread to handle each new connection or using some kind of event based system.

However, in simple one to one connections that complexity is not required.