Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# socket connect timeout

public static class SocketExtensions
{
    /// <summary>
    /// Connects the specified socket.
    /// </summary>
    /// <param name="socket">The socket.</param>
    /// <param name="endpoint">The IP endpoint.</param>
    /// <param name="timeout">The timeout.</param>
    public static void Connect(this Socket socket, EndPoint endpoint, TimeSpan timeout)
    {
        var result = socket.BeginConnect(endpoint, null, null);

        bool success = result.AsyncWaitHandle.WaitOne(timeout, true);
        if (success)
        {
            socket.EndConnect(result);
        }
        else
        {
            socket.Close();
            throw new SocketException(10060); // Connection timed out.
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to get hours and minutes from second in c# 
Csharp :: Unity Rigidbody how to set zero momentum 
Csharp :: convert string into double in c# 
Csharp :: create list c# 
Csharp :: dota2 
Csharp :: how to do time.deltatime in c# 
Csharp :: two variable in one loop in one line c# 
Csharp :: c# unity detect any keyboard input but not mouse input 
Csharp :: c# console save file 
Csharp :: random.range unity not working 
Csharp :: escape double quotes c# 
Csharp :: c# list string return concatenate 
Csharp :: c# bitmap to byte array 
Csharp :: get client ip address c# 
Csharp :: sort array by parity 
Csharp :: rotate player unity 
Csharp :: c-sharp - get current page url/path/host 
Csharp :: c# update control from another thread 
Csharp :: char contains c# 
Csharp :: how to move object with keyboard in unity 3D 
Csharp :: c# datagridview hide row selector 
Csharp :: unity action example 
Csharp :: connection string in asp.net with username and password 
Csharp :: unity button press 
Csharp :: c# string from b64 
Csharp :: c# see if string is int 
Csharp :: create new .net project 
Csharp :: rigidbody velocity c# unity 
Csharp :: c# dictionary keys to list 
Csharp :: difference between boxing and unboxing in c# 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =