Skip to content

Latest commit

 

History

History
executable file
·
32 lines (27 loc) · 695 Bytes

File metadata and controls

executable file
·
32 lines (27 loc) · 695 Bytes

Random String 64 Bytes

This function will return a random 64 Bytes string useful for pings (example usage):

static bool PingBool(string address)
{
    bool result;
    Ping ping = new Ping();
    
    try
    {
        string data = RandomString64Bytes();
        byte[] buffer = Encoding.ASCII.GetBytes(data);
        int timeout = 50;
        PingOptions options = new PingOptions(128, true);
                    
        PingReply rep = ping.Send(address, timeout, buffer, options);
        result = rep.Status == IPStatus.Success;
    }
    catch (PingException)
    {
        result = true;
    }
    finally
    {
        ping.Dispose();
    }
    
    return result;
}