コード例 #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            tcpAsyncServer = new TCPAsyncServer();
            tcpAsyncServer.SaveDataProcessCallback = new SaveDataProcessCallbackDelegate(CP1616_NoAddr_Packet.SaveDataProcessCallbackProc);
            tcpAsyncServer.ErrorServerEvent       += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
            tcpAsyncServer.AcceptServerEvent      += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
            tcpAsyncServer.DisconnectServerEvent  += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
            tcpAsyncServer.ReceiveServerEvent     += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);


            mcuClientContext = null;
            if (!int.TryParse(tbPort.Text, out tcpAsyncServer.TCPServerPort))
            {
                MessageBox.Show("输入的端口号格式有问题!!");
                return;
            }
            toolStripButton1.Text = "停止";
            tcpAsyncServer.Start();
            NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
            NetLog("服务器启动\r\n");
            NetLog("\r\n");
            listView1_Resize(null, null);
            timer1.Enabled = true;
            DateTime dt = DateTime.Now;
            string   filePT, fileMS, fileTC, fileLA;

            filePT = System.Windows.Forms.Application.StartupPath + "\\TextLog\\PT" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), filePT, false);
            fileMS = System.Windows.Forms.Application.StartupPath + "\\TextLog\\MS" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileMS, false);
            fileTC = System.Windows.Forms.Application.StartupPath + "\\TextLog\\TC" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileTC, false);
            fileLA = System.Windows.Forms.Application.StartupPath + "\\TextLog\\LA" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileLA, false);
        }
コード例 #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            iniFileOP.iniFilePath = System.Windows.Forms.Application.StartupPath + "\\miConfig.ini";
            if (iniFileOP.Read("Work Setting", "bPrint") == "1")
            {
                bPrint = true;
            }
            else
            {
                bPrint = false;
            }
            pathPDF        = iniFileOP.Read("Work Setting", "pathPDF");
            CurveDataTable = new Hashtable();
            tcpAsyncServer = new TCPAsyncServer();
            tcpAsyncServer.TCPServerPort           = 8000;
            tcpAsyncServer.ErrorServerEvent       += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
            tcpAsyncServer.AcceptServerEvent      += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
            tcpAsyncServer.DisconnectServerEvent  += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
            tcpAsyncServer.ReceiveServerEvent     += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);
            tcpAsyncServer.SaveDataProcessCallback = new SaveDataProcessCallbackDelegate(easyStringPacket.SaveDataProcessCallbackProc);
            tcpAsyncServer.Start();
            textBox1.AppendText("服务启动" + "\r\n");
            byte[] xx = NetPacket.MakeStringPacket("123");

            this.reportViewer1.RefreshReport();
        }
コード例 #3
0
 public Form2(TCPAsyncServer _tcpAsyncServer, string _ip, ClientContext _cc)
 {
     InitializeComponent();
     tcpAsyncServer = _tcpAsyncServer;
     strIP          = _ip;
     clientContext  = _cc;
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: wangf0228GitHub/ZXJ
        private void Form1_Load(object sender, EventArgs e)
        {
            CP1616_NoAddr_Packet.bVerify = false;
            tcpAsyncServer = new TCPAsyncServer();
            tcpAsyncServer.SaveDataProcessCallback = new SaveDataProcessCallbackDelegate(CP1616_NoAddr_Packet.SaveDataProcessCallbackProc);
            tcpAsyncServer.ErrorServerEvent       += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
            tcpAsyncServer.AcceptServerEvent      += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
            tcpAsyncServer.DisconnectServerEvent  += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
            tcpAsyncServer.ReceiveServerEvent     += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);
            if (!int.TryParse(tbPort.Text, out tcpAsyncServer.TCPServerPort))
            {
                MessageBox.Show("输入的端口号格式有问题!!");
                return;
            }
            toolStripButton1.Text = "停止";
            mcuClientContext      = null;
            tcpAsyncServer.Start();
            NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
            NetLog("服务器启动\r\n");
            NetLog("\r\n");
            timer1.Enabled = true;
            DateTime dt = DateTime.Now;

            fileHY = System.Windows.Forms.Application.StartupPath + "\\TextLog\\HY" + String.Format("{0:D4}{1:D2}{2:D2}{3:D2}{4:D2}{5:D2}", dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileHY, false);
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: wangf0228GitHub/WFLib
 private void Form1_Load(object sender, EventArgs e)
 {
     toolStripComboBox2.SelectedIndex = 0;
     tcpAsyncServer = new TCPAsyncServer();
     tcpAsyncServer.ErrorServerEvent      += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
     tcpAsyncServer.AcceptServerEvent     += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
     tcpAsyncServer.DisconnectServerEvent += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
     tcpAsyncServer.ReceiveServerEvent    += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);
 }
コード例 #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            tcpAsyncServer = new TCPAsyncServer();
            tcpAsyncServer.SaveDataProcessCallback = new SaveDataProcessCallbackDelegate(CP1616_NoAddr_Packet.SaveDataProcessCallbackProc);
            tcpAsyncServer.ErrorServerEvent       += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
            tcpAsyncServer.AcceptServerEvent      += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
            tcpAsyncServer.DisconnectServerEvent  += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
            tcpAsyncServer.ReceiveServerEvent     += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);
            tcpAsyncServer.TCPServerPort           = 6000;

            mcuClientContext = null;

            toolStripButton1.Text = "停止";
            tcpAsyncServer.Start();
            NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
            NetLog("服务器启动\r\n");
            NetLog("\r\n");
            listView1_Resize(null, null);
            timer1.Enabled = true;
        }
コード例 #7
0
        public Form1()
        {
            InitializeComponent();
            tcpAsyncServer = new TCPAsyncServer();
            tcpAsyncServer.SaveDataProcessCallback = new SaveDataProcessCallbackDelegate(CP1616_NoAddr_Packet.SaveDataProcessCallbackProc);
            tcpAsyncServer.ErrorServerEvent       += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
            tcpAsyncServer.AcceptServerEvent      += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
            tcpAsyncServer.DisconnectServerEvent  += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
            tcpAsyncServer.ReceiveServerEvent     += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);

            if (!int.TryParse(tbPort.Text, out tcpAsyncServer.TCPServerPort))
            {
                MessageBox.Show("输入的端口号格式有问题!!");
                return;
            }
            toolStripButton1.Text = "停止";
            tcpAsyncServer.Start();
            NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
            NetLog("服务器启动\r\n");
            NetLog("\r\n");
            listView1_Resize(null, null);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: GrigoryanArtem/Sockets
        static void Main(string[] args)
        {
            TCPAsyncServer server = new TCPAsyncServer(args[0], Convert.ToInt32(args[1]));

            server.Start();
        }
コード例 #9
0
ファイル: Form2.cs プロジェクト: wangf0228GitHub/ZXJ
 public Form2(TCPAsyncServer _tcpAsyncServer)
 {
     InitializeComponent();
     tcpAsyncServer = _tcpAsyncServer;
 }
コード例 #10
0
 public void Dispose()
 {
     _socket   = null;
     _protocol = null;
 }
コード例 #11
0
 /// <summary>
 /// 构造函数,建立一个未初始化的服务器实例
 /// </summary>
 /// <param name="numConnections">服务器的最大连接数据</param>
 /// <param name="bufferSize"></param>
 public SocketServer(Int32 numConnections, Int32 bufferSize, Int32 port, string ip)
 {
     _protocol          = new BaseProtocol();
     _protocol.Receive += _protocol_Receive;
     _socket            = new TCPAsyncServer(port, numConnections, bufferSize, _protocol, 0);
 }