public System.Threading.Tasks.Task ConnectAsync(System.Net.IPAddress address, int port) { throw null; }
public System.Threading.Tasks.Task ConnectAsync(System.Net.IPAddress[] addresses, int port) { throw null; }
public System.Threading.Tasks.Task ConnectAsync(string host, int port) { throw null; }
+ public System.Threading.Tasks.Task ConnectAsync(System.Net.IPEndPoint remoteEP) { throw null; }
public System.Threading.Tasks.ValueTask ConnectAsync(System.Net.IPAddress address, int port, System.Threading.CancellationToken cancellationToken) { throw null; }
public System.Threading.Tasks.ValueTask ConnectAsync(System.Net.IPAddress[] addresses, int port, System.Threading.CancellationToken cancellationToken) { throw null; }
public System.Threading.Tasks.ValueTask ConnectAsync(string host, int port, System.Threading.CancellationToken cancellationToken) { throw null; }
+ public System.Threading.Tasks.ValueTask ConnectAsync(System.Net.IPEndPoint remoteEP, System.Threading.CancellationToken cancellationToken) { throw null; }
public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
public void EndConnect(System.IAsyncResult asyncResult) { }
public Task ConnectAsync(IPAddress[] addresses, int port) =>
CompleteConnectAsync(Client.ConnectAsync(addresses, port));
+ /// <summary>
+ /// Connects the client to a remote TCP host using the specified endpoint as an asynchronous operation.
+ /// </summary>
+ /// <param name="remoteEP">The <see cref="IPEndPoint"/> to which you intend to connect.</param>
+ /// <returns>A task representing the asynchronous operation.</returns>
+ public Task ConnectAsync(IPEndPoint remoteEP) =>
+ CompleteConnectAsync(Client.ConnectAsync(remoteEP));
+
private async Task CompleteConnectAsync(Task task)
{
await task.ConfigureAwait(false);
public ValueTask ConnectAsync(IPAddress[] addresses, int port, CancellationToken cancellationToken) =>
CompleteConnectAsync(Client.ConnectAsync(addresses, port, cancellationToken));
+ /// <summary>
+ /// Connects the client to a remote TCP host using the specified endpoint as an asynchronous operation.
+ /// </summary>
+ /// <param name="remoteEP">The <see cref="IPEndPoint"/> to which you intend to connect.</param>
+ /// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
+ /// <returns>A task representing the asynchronous operation.</returns>
+ public ValueTask ConnectAsync(IPEndPoint remoteEP, CancellationToken cancellationToken) =>
+ CompleteConnectAsync(Client.ConnectAsync(remoteEP, cancellationToken));
+
private async ValueTask CompleteConnectAsync(ValueTask task)
{
await task.ConfigureAwait(false);
[InlineData(6)]
[InlineData(7)]
[InlineData(8)]
+ [InlineData(9)]
+ [InlineData(10)]
public async Task ConnectAsync_DnsEndPoint_Success(int mode)
{
using (var client = new DerivedTcpClient())
break;
case 8:
addresses = await Dns.GetHostAddressesAsync(host);
+ await client.ConnectAsync(new IPEndPoint(addresses[0], port));
+ break;
+ case 9:
+ addresses = await Dns.GetHostAddressesAsync(host);
+ await client.ConnectAsync(new IPEndPoint(addresses[0], port), CancellationToken.None);
+ break;
+ case 10:
+ addresses = await Dns.GetHostAddressesAsync(host);
await client.ConnectAsync(addresses, port, CancellationToken.None);
break;
}