コード例 #1
0
 // Destruct all connections.
 public void DeinitRobot()
 {
     if (checkStateThread != null)
     {
         checkStateThread.Abort();
     }
     if (checkStateThread2 != null)
     {
         checkStateThread2.Abort();
     }
     if (MessageReader1 != null)
     {
         MessageReader1.Close();
     }
     if (MessageReader2 != null)
     {
         MessageReader2.Close();
     }
     if (DataStream1 != null)
     {
         DataStream1.Close();
     }
     if (DataStream2 != null)
     {
         DataStream2.Close();
     }
     if (Client1 != null)
     {
         Client1.Close();
     }
     if (Client2 != null)
     {
         Client2.Close();
     }
 }
コード例 #2
0
 public void Close()
 {
     if (client != null)
     {
         client.Close();
     }
     clockTicker.Dispose();
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: dongcheolpark/INCAL
        public static void Server_app()
        {
            while (true)
            {
                try
                {
                    using (SqlConnection conn = new SqlConnection(strConn))
                    {
                        conn.Open();
                        Server2.Listen(10);

                        Client2 = Server2.Accept();
                        console_command.Showip(Client2);
                        if (Client2.Connected)
                        {
                            DbControll.Del();
                            var cmd = new SqlCommand("select * from Homework", conn);
                            var rdr = cmd.ExecuteReader();
                            while (rdr.Read())
                            {
                                Send(Client2, (string)rdr["Subject"]);

                                //Send(Client2, (string)rdr[1]);

                                Send(Client2, (string)rdr["T_Name"]);

                                Send(Client2, (string)rdr["Contents"]);

                                //Send(Client2, (string)rdr[4]);

                                Send(Client2, (string)rdr["Title"]);

                                Send(Client2, Convert.ToDateTime(rdr["date"]).ToString("dd/MM/yyyy"));
                            }
                            Send(Client2, "EOF");
                            rdr.Close();
                            Client2.Close();
                        }
                    }
                }
                catch (System.Net.Sockets.SocketException socketEx)
                {
                    Console.WriteLine("[Error]:{0}", socketEx.Message);
                }
                catch (System.Exception commonEx)
                {
                    Console.WriteLine("[Error]:{0}", commonEx.Message);
                }
            }
        }
コード例 #4
0
        private void checkStateController()
        {
            while (true)
            {
                Thread.Sleep(1000);

                if (Client2.Connected == false)
                {
                    try
                    {
                        if (MessageReader2 != null)
                        {
                            MessageReader2.Close();
                        }
                        if (DataStream2 != null)
                        {
                            DataStream2.Close();
                        }
                        if (Client2 != null)
                        {
                            Client2.Close();
                        }

                        Client2         = new TcpClient();
                        Client2.NoDelay = true;
                        Client2.Connect(IPAddress.Parse(ip), MessagePort);

                        if (Client2.Connected)
                        {
                            DataStream2    = Client1.GetStream();
                            MessageReader2 = new StreamReader(DataStream2);
                        }
                    }
                    catch (ArgumentNullException ex1)
                    {
                        Console.WriteLine("ArgumentNullException = " + ex1);
                    }
                    catch (SocketException ex2)
                    {
                        Console.WriteLine("SocketException = " + ex2);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception = " + e);
                    }
                }
            }
        }
コード例 #5
0
ファイル: Authentication.xaml.cs プロジェクト: nauhtnn/sQz
 private void W_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     bRunning = false;
     PopupMgr.Singleton.IsOK = false;
     mClnt.Close();
 }
コード例 #6
0
ファイル: ExamPage.xaml.cs プロジェクト: nauhtnn/sQz
 private void W_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     bRunning = false;
     mClnt.Close();
     WPopup.s.Exit();
 }