Error: TCP Provider: Error code 0x2746. During the Sql setup in linux through terminal

[UPDATE 17.03.2020: Microsoft has released SQL Server 2019 CU3 with an Ubuntu 18.04 repository. See: https://techcommunity.microsoft.com/t5/sql-server/sql-server-2019-now-available-on-ubuntu-18-04-supported-on-sles/ba-p/1232210 . I hope this is now fully compatible without any ssl problems. Haven’t tested it jet.] Reverting to 14.0.3192.2-2 helps. But it’s possible to solve the problem also using the method indicated by Ola774, not only in case of … Read more

Async lock not allowed

Looks like the problem that you have is that threads will block while acquiring the lock, so your method is not completely async. To solve this you can use SemaphoreSlim.WaitAsync private readonly SemaphoreSlim readLock = new SemaphoreSlim(1, 1); public async Task UpdateDetailsAsync() { //I want every request to wait their turn before requesting (using the … Read more

How to check if TcpClient Connection is closed?

I wouldn’t recommend you to try write just for testing the socket. And don’t relay on .NET’s Connected property either. If you want to know if the remote end point is still active, you can use TcpConnectionInformation: TcpClient client = new TcpClient(host, port); IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties(); TcpConnectionInformation[] tcpConnections = ipProperties.GetActiveTcpConnections().Where(x => x.LocalEndPoint.Equals(client.Client.LocalEndPoint) && x.RemoteEndPoint.Equals(client.Client.RemoteEndPoint)).ToArray(); … Read more

How to set the timeout for a TcpClient?

You would need to use the async BeginConnect method of TcpClient instead of attempting to connect synchronously, which is what the constructor does. Something like this: var client = new TcpClient(); var result = client.BeginConnect(“remotehost”, this.Port, null, null); var success = result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(1)); if (!success) { throw new Exception(“Failed to connect.”); } // we have connected … Read more

In C#, how to check if a TCP port is available?

Since you’re using a TcpClient, that means you’re checking open TCP ports. There are lots of good objects available in the System.Net.NetworkInformation namespace. Use the IPGlobalProperties object to get to an array of TcpConnectionInformation objects, which you can then interrogate about endpoint IP and port. int port = 456; //<— This is your value bool … Read more