Future<Socket> connect(host, int port, {sourceAddress})

Creates a new socket connection to the host and port and returns a Future that will complete with either a Socket once connected or an error if the host-lookup or connection failed.

host can either be a String or an InternetAddress. If host is a String, connect will perform a InternetAddress.lookup and try all returned InternetAddresses, until connected. Unless a connection was established, the error from the first failing connection is returned.

The argument sourceAddress can be used to specify the local address to bind when making the connection. sourceAddress can either be a String or an InternetAddress. If a String is passed it must hold a numeric IP address.

Source

external static Future<Socket> connect(host, int port, {sourceAddress});