// Token: 0x0600001C RID: 28 RVA: 0x00009F5C File Offset: 0x0000815C
        private static void SocketConnectCompleted(object sender, SocketAsyncEventArgs e)
        {
            ConnectAsyncExtension.DnsConnectState dnsConnectState = e.UserToken as ConnectAsyncExtension.DnsConnectState;
            if (e.SocketError == SocketError.Success)
            {
                ConnectAsyncExtension.ClearSocketAsyncEventArgs(e);
                dnsConnectState.Callback((Socket)sender, dnsConnectState.State, e, null);
                return;
            }
            if (e.SocketError != SocketError.HostUnreachable && e.SocketError != SocketError.ConnectionRefused)
            {
                ConnectAsyncExtension.ClearSocketAsyncEventArgs(e);
                dnsConnectState.Callback(null, dnsConnectState.State, e, null);
                return;
            }
            Socket    socket;
            IPAddress nextAddress = ConnectAsyncExtension.GetNextAddress(dnsConnectState, out socket);

            if (nextAddress == null)
            {
                ConnectAsyncExtension.ClearSocketAsyncEventArgs(e);
                e.SocketError = SocketError.HostUnreachable;
                dnsConnectState.Callback(null, dnsConnectState.State, e, null);
                return;
            }
            e.RemoteEndPoint = new IPEndPoint(nextAddress, dnsConnectState.Port);
            if (!socket.ConnectAsync(e))
            {
                ConnectAsyncExtension.SocketConnectCompleted(socket, e);
            }
        }
 // Token: 0x06000018 RID: 24 RVA: 0x00009D20 File Offset: 0x00007F20
 private static void ConnectAsyncpublic(this EndPoint remoteEndPoint, EndPoint localEndPoint, ConnectedCallback callback, object state)
 {
     if (remoteEndPoint is DnsEndPoint)
     {
         DnsEndPoint  dnsEndPoint = (DnsEndPoint)remoteEndPoint;
         IAsyncResult asyncResult = Dns.BeginGetHostAddresses(dnsEndPoint.Host, new AsyncCallback(ConnectAsyncExtension.OnGetHostAddresses), new ConnectAsyncExtension.DnsConnectState
         {
             Port          = dnsEndPoint.Port,
             Callback      = callback,
             State         = state,
             LocalEndPoint = localEndPoint
         });
         if (asyncResult.CompletedSynchronously)
         {
             ConnectAsyncExtension.OnGetHostAddresses(asyncResult);
             return;
         }
     }
     else
     {
         SocketAsyncEventArgs e = ConnectAsyncExtension.CreateSocketAsyncEventArgs(remoteEndPoint, callback, state);
         Socket socket          = new Socket(remoteEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
         if (localEndPoint != null)
         {
             socket.ExclusiveAddressUse = false;
             socket.Bind(localEndPoint);
         }
         socket.ConnectAsync(e);
     }
 }
        // Token: 0x0600001B RID: 27 RVA: 0x00009E24 File Offset: 0x00008024
        private static void OnGetHostAddresses(IAsyncResult result)
        {
            ConnectAsyncExtension.DnsConnectState dnsConnectState = result.AsyncState as ConnectAsyncExtension.DnsConnectState;
            IPAddress[] array;
            try
            {
                array = Dns.EndGetHostAddresses(result);
            }
            catch (Exception exception)
            {
                dnsConnectState.Callback(null, dnsConnectState.State, null, exception);
                return;
            }
            if (array == null || array.Length == 0)
            {
                dnsConnectState.Callback(null, dnsConnectState.State, null, new SocketException(11001));
                return;
            }
            dnsConnectState.Addresses = array;
            ConnectAsyncExtension.CreateAttempSocket(dnsConnectState);
            Socket    socket;
            IPAddress nextAddress = ConnectAsyncExtension.GetNextAddress(dnsConnectState, out socket);

            if (nextAddress == null)
            {
                dnsConnectState.Callback(null, dnsConnectState.State, null, new SocketException(10047));
                return;
            }
            if (dnsConnectState.LocalEndPoint != null)
            {
                try
                {
                    socket.ExclusiveAddressUse = false;
                    socket.Bind(dnsConnectState.LocalEndPoint);
                }
                catch (Exception exception2)
                {
                    dnsConnectState.Callback(null, dnsConnectState.State, null, exception2);
                    return;
                }
            }
            SocketAsyncEventArgs socketAsyncEventArgs = new SocketAsyncEventArgs();

            socketAsyncEventArgs.Completed += ConnectAsyncExtension.SocketConnectCompleted;
            IPEndPoint remoteEndPoint = new IPEndPoint(nextAddress, dnsConnectState.Port);

            socketAsyncEventArgs.RemoteEndPoint = remoteEndPoint;
            socketAsyncEventArgs.UserToken      = dnsConnectState;
            if (!socket.ConnectAsync(socketAsyncEventArgs))
            {
                ConnectAsyncExtension.SocketConnectCompleted(socket, socketAsyncEventArgs);
            }
        }