openTcpChannel method

Channel openTcpChannel(
  1. String sourceHost,
  2. int sourcePort,
  3. String destHost,
  4. int destPort,
  5. ChannelCallback cb, {
  6. VoidCallback connected,
  7. StringCallback error,
})

Request remote opens a new TCP channel to destHost:destPort.

Implementation

Channel openTcpChannel(String sourceHost, int sourcePort, String destHost,
    int destPort, ChannelCallback cb,
    {VoidCallback connected, StringCallback error}) {
  if (socket == null || state <= SSHTransportState.FIRST_NEWKEYS) return null;
  if (debugPrint != null) debugPrint('openTcpChannel to $destHost:$destPort');
  Channel chan = channels[nextChannelId] = Channel(
      localId: nextChannelId++,
      windowS: initialWindowSize,
      cb: cb,
      error: error,
      connected: connected);
  nextChannelId++;
  writeCipher(MSG_CHANNEL_OPEN_TCPIP(
      'direct-tcpip',
      chan.localId,
      chan.windowS,
      maxPacketSize,
      destHost,
      destPort,
      sourceHost,
      sourcePort));
  return chan;
}