Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# check port in remote pc

var result = false;
using (var client = new TcpClient())
{
    try
    {
        client.ReceiveTimeout = timeout * 1000;
        client.SendTimeout = timeout * 1000;
        var asyncResult = client.BeginConnect(host, port, null, null);
        var waitHandle = asyncResult.AsyncWaitHandle;
        try
        {
            if (!asyncResult.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(timeout), false))
            {
                // wait handle didn't came back in time
                client.Close();
            }
            else
            {
                // The result was positiv
                result = client.Connected;
            }
            // ensure the ending-call
            client.EndConnect(asyncResult);
        }
        finally
        {
            // Ensure to close the wait handle.
            waitHandle.Close();
        }
    }
    catch
    {
    }
}
return result;
Comment

PREVIOUS NEXT
Code Example
Csharp :: if input.get touch 
Csharp :: get first number in string C# 
Csharp :: cant see my classes in inspector 
Csharp :: referans tipi nedir c# 
Csharp :: disable alt + f4 in c# forms 
Csharp :: convert list to datatable c# 
Csharp :: how to iterate string in c# 
Csharp :: wpf keydown detect if control key is down 
Csharp :: count number of rows in a table in c# 
Csharp :: wpf StrokeDashArray 
Csharp :: entityframework index 
Csharp :: example of List c# 
Csharp :: instantiate an array in c# 
Csharp :: generate a dropdown list from array data using razor .net mvc 
Csharp :: c# clear panel 
Csharp :: web.config customerrors not working 
Csharp :: c# async and await example 
Csharp :: foreach for IEnumerable 
Csharp :: show datatable c# 
Csharp :: strinng.indexOf c# 
Csharp :: oauth API with the Access Token to retrieve some of users information. 
Csharp :: generic interface c# 
Csharp :: matrix transpose c# 
Csharp :: static keyword 
Csharp :: what is int.parse in c# 
Csharp :: rotate skybox on x axis unity 
Csharp :: scaffolding in vs22 asp.net 6 
Csharp :: discord bot c# how to refresh message 
Csharp :: Unity Scene Load by BuildIndex 
Csharp :: project camera view to texture 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =