| 124 | } |
| 125 | |
| 126 | void EthernetClient::stop() { |
| 127 | if (_sock == MAX_SOCK_NUM) |
| 128 | return; |
| 129 | |
| 130 | // attempt to close the connection gracefully (send a FIN to other side) |
| 131 | disconnect(_sock); |
| 132 | unsigned long start = millis(); |
| 133 | |
| 134 | // wait a second for the connection to close |
| 135 | while (status() != SnSR::CLOSED && millis() - start < 1000) |
| 136 | delay(1); |
| 137 | |
| 138 | // if it hasn't closed, close it forcefully |
| 139 | if (status() != SnSR::CLOSED) |
| 140 | close(_sock); |
| 141 | |
| 142 | EthernetClass::_server_port[_sock] = 0; |
| 143 | _sock = MAX_SOCK_NUM; |
| 144 | } |
| 145 | |
| 146 | uint8_t EthernetClient::connected() { |
| 147 | if (_sock == MAX_SOCK_NUM) return 0; |
nothing calls this directly
no test coverage detected