Beispiel #1
0
        // Connect: try to connect to an IRC server
        public bool Connect(ConnectionInformations ci)
        {
            // If the client is already connected,
            if (IsConnected)
            {
                // just close everything
                client.Close();
                stream.Close();
            }

            // ReInitialize the client and try to connect
            try
            {
                client = new TcpClient();
                client.Connect(ci.Address, ci.Port);
            }
            catch (SocketException)
            {
                // If here, the connection went wrong, just return
                return(false);
            }

            // Prepare the stream, reader and writer
            stream = client.GetStream();
            writer = new StreamWriter(stream, new UTF8Encoding(false));
            reader = new StreamReader(stream, new UTF8Encoding(false));

            // Start the receiving thread
            Thread t = new Thread(Read);

            t.Start();

            // Return
            return(true);
        }
Beispiel #2
0
        // Connect: try to connect to an IRC server
        public bool Connect(ConnectionInformations ci)
        {
            // If the client is already connected,
            if (IsConnected)
            {
                // just close everything
                client.Close();
                stream.Close();
            }

            // ReInitialize the client and try to connect
            try
            {
                client = new TcpClient();
                client.Connect(ci.Address, ci.Port);
            }
            catch (SocketException)
            {
                // If here, the connection went wrong, just return
                return false;
            }

            // Prepare the stream, reader and writer
            stream = client.GetStream();
            writer = new StreamWriter(stream, new UTF8Encoding(false));
            reader = new StreamReader(stream, new UTF8Encoding(false));

            // Start the receiving thread
            Thread t = new Thread(Read);
            t.Start();

            // Return
            return true;
        }