TCPSocket broadcasts multiple times to same client

With TCPServer, when a client connects, then disconnects, then reconnects again, the print() methods on TCPSocket end up sending the data more than once to the client.

TCPServer server(999);

void setup() {

int count = 0;
void loop() {
    if (server.available()) {
        char buf[20];
        sprintf(buf, "%d", count++);
        server.print("count: ");

After flashing this to the core:

$ telnet 999
Connected to
Escape character is '^]'.
count: 0
count: 1
count: 2
count: 3
count: 4

I then hit ‘^]’ and exit telnet, closing the connection.

The next time I connect, I get no output.

The third time, I get duplicated output sent to the same client:

count: count: 1515

count: count: 1616

count: count: 1717

count: count: 1818

count: count: 1919

Each call to print()/println() is being sent to the client twice, almost as if the same client appears multiple times in the list of server clients.

I get different behaviour (more correct) if I open a multiple telnet sessions. Then each client gets the correct output (1 copy of the data), and it works after closing and reopening 3rd connected client. (The 2nd session still gets no data, and the 4th hangs indefinitely until a timeout.)

However, the same test, but closing the first connected client causes all others to hang. They don’t resume until another client connects, which then presumably fills the first slot and allows the others proceed.