close method

Future close()

will wait until all socket data has been flushed to the socket and then will close it.

Implementation

Future close() async {
  stopTrying();
  await _socket?.flush();
  await _socket?.close();
}