示例#1
0
        private static void ConnectCallback(IAsyncResult ar)
        {
            //Catch exception when connection cannot be established
            //and output the error to login window.
            try {
                socket.EndConnect(ar);
            } catch (Exception e) {
                LoginWindow.WriteError(e.Message);
                return;
            }

            LoginWindow.ConnectionSuccessful();
            connected = true;
            //Establish infinite listening loop for receiving network data.
            while (connected)
            {
                OnReceive();
            }
        }