client.connected() returns true even if the connection is broken!

Hello everyone,
I have a simple server code that accepts a connection and returns whatever the client send in back to it. The server works fine if each client correctly closes the connection (by calling closeSocket(socket) on the client side) when the client finishes. But if I close an active connection in the middle of the connection, the next connection made by a client won't be accepted by the server.
I have searched for solution the past few days but no luck.
Please help!

#include <Bridge.h>
#include <BridgeServer.h>
#include <BridgeClient.h>

const int PORT = 5000;

BridgeServer server(PORT);

void setup() {
 //begin bridge
 //begin server


void loop() {
  //waiting for connection
  BridgeClient client = server.accept();

  //if there is a connection
  if (client) {
    while (client.connected()) {
      if (client.available() > 0) {
      //receive a 1-byte data from client
      byte data =;
      //send data back to client
      //wait a bit


Welcome to the wonderful world of Ethernet. The only way to know if a connection is present, is to receive data from it. The only way to know if it is lost, is to NOT receive data from it. So, if you want to continuously monitor the connection state, you have to continuously send and receive data, usually by sending "heartbeat" packet at intervals. There is NO way to reliably tell whether the other device is connected without attempting a data transfer.

Ray L.

I guessed the linux is not fully implemented on network operations. Well it's understandable considering it's tiny home.

What library? Ethernet? WiFi? WiFi Link?

What library? Ethernet? WiFi? WiFi Link?

I guess I'm using BridgeServer and BridgeClient libraries. And the communication is over wifi.