Test() public static method

Tests a connection to see if it is valid
public static Test ( NetworkStream stream ) : bool
stream System.Net.Sockets.NetworkStream Stream to test
return bool
Example #1
0
        /// <summary>
        /// Tests the server to see if the connection is valid
        /// </summary>
        /// <returns>True if the connection is valid, false otherwise</returns>
        public bool Test()
        {
            bool result = false;

            try
            {
                using (TcpClient client = new TcpClient())
                {
                    client.Connect(serverEndPoint);
                    NetworkStream networkStream = client.GetStream();

                    result = Message.Test(networkStream);
                }
            }
            catch (SocketException) { return(false); }

            return(result);
        }