示例#1
0
        void InitSocket()//初始化SOCKET
        {
            serverSocket = new SocketLib.ServerSocketSync(
                int.Parse(ConfigurationManager.AppSettings["SKPORT"].ToString()),
                int.Parse(ConfigurationManager.AppSettings["MaxConnection"].ToString())
                );

            serverSocket.OnCloseConnection += new SocketLib.ServerSocketSync.CloseConnection(serverSocket_OnCloseConnection);
            serverSocket.OnConnection      += new SocketLib.ServerSocketSync.Connection(serverSocket_OnConnection);
            serverSocket.OnError           += new SocketLib.ServerSocketSync.Error(serverSocket_OnError);
            serverSocket.OnReceivedBigData += new SocketLib.ServerSocketSync.ReceivedBigData(serverSocket_OnReceivedBigData);
            serverSocket.OnSendData        += new SocketLib.ServerSocketSync.SendData(serverSocket_OnSendData);
            serverSocket.RunServer(ConfigurationManager.AppSettings["ServiceIp"].ToString());

            if (serverSocket.IsBound)
            {
                AddListStatus("Socket->服务已启动......");
                AddListStatus("Socket->服务IP:" + serverSocket.LocalEndPoint.ToString() + ",开始监听......");
            }
            else
            {
                AddListStatus("Socket->服务启动失败!请查看原因后重试!");
                serverSocket = null;
            }
            listBox_Status.Items.Add("");
        }
示例#2
0
        private void button_Stop_Click(object sender, EventArgs e)
        {
            hours   = 0;
            minute  = 0;
            seconds = 0;

            Mem.Abort();
            Mem = null;

            Time.Abort();
            Time = null;

            label_Mem.Text     = "已停止";
            label_RunTime.Text = "已停止";

            button_Stop.Enabled       = false;
            button_Run.Enabled        = true;
            button_ClearCache.Enabled = false;

            listBox_Online.Items.Clear();
            listBox_Status.Items.Clear();

            Remotingserver.StopListening(null);

            if (Remotingserver.ChannelData == null)
            {
                AddListStatus("Remoting->通道已关闭!");
            }
            else
            {
                AddListStatus("Remoting->通道关闭失败!");
            }


            serverSocket.CloseServer();
            serverSocket = null;
            AddListStatus("Socket->通道已关闭!");


            DB_CaChe.Dispose();
        }