public async Task Properties_PersistAfterConnect()
{
using (TcpClient client = new TcpClient())
{
// Set a few properties
client.LingerState = new LingerOption(true, 1);
client.ReceiveTimeout = 42;
client.SendTimeout = 84;
await client.ConnectAsync(System.Net.Test.Common.Configuration.Sockets.SocketServer.IdnHost, System.Net.Test.Common.Configuration.Sockets.SocketServer.Port);
// Verify their values remain as were set before connecting
Assert.True(client.LingerState.Enabled);
Assert.Equal(1, client.LingerState.LingerTime);
Assert.Equal(42, client.ReceiveTimeout);
Assert.Equal(84, client.SendTimeout);
// Note: not all properties can be tested for this on all OSes, as some
// properties are modified by the OS, e.g. Linux will double whatever
// buffer size you set and return that double value. OSes may also enforce
// minimums and maximums, silently capping to those amounts.
}
}