connect method

Future<void> connect()

Connects to the SOCKS socket.

Returns: A Future that resolves to void.

Implementation

Future<void> connect() async {
  // Greeting and method selection.
  _socksSocket.add([0x05, 0x01, 0x00]);

  // Wait for server response.
  var response = await _responseController.stream.first;

  // Check if the connection was successful.
  if (response[1] != 0x00) {
    throw Exception(
        'socks_socket.connect(): Failed to connect to SOCKS5 proxy.');
  }

  return;
}