enterPassiveMode method

Future<void> enterPassiveMode()

Implementation

Future<void> enterPassiveMode() async {
  try {
    dataListener = await ServerSocket.bind(InternetAddress.anyIPv4, 0);
    int port = dataListener!.port;
    int p1 = port >> 8;
    int p2 = port & 0xFF;
    var address = (await _getIpAddress()).replaceAll('.', ',');
    sendResponse('227 Entering Passive Mode ($address,$p1,$p2)');

    /// assigning the future to make sure it finishes before running any other operation
    /// check [openDataConnection]
    _gettingDataSocket =
        waitForClientDataSocket(timeout: Duration(seconds: 30));
  } catch (e) {
    sendResponse('425 Can\'t enter passive mode');
    logger.generalLog('Error entering passive mode: $e');
  }
}