/// <summary>
 ///
 /// </summary>
 /// <param name="sokMsg">通信套接字</param>
 /// <param name="dgShowMsg">向主窗体文本框显示消息的方法委托</param>
 public ConnectionClient(Socket sokMsg, DGShowMsg dgShowMsg, DGBagsNum bagsNum)
 {
     this.sokMsg    = sokMsg;
     this.dgShowMsg = dgShowMsg;//实例化委托,此后dgShowMsg(前)拥有了dgShowMsg(后)的特性
     this.BagsNum   = bagsNum;
     this.threadMsg = new Thread(RecMsg);
     this.threadMsg.IsBackground = true;
     this.threadMsg.Start();
 }
예제 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sokMsg">通信套接字</param>
        /// <param name="dgShowMsg">向主窗体文本框显示消息的方法委托</param>
        public ConnectionClient(Socket sokMsg, DGShowMsg dgShowMsg, DGShowMsg dgRemoveConnection)
        {
            this.sokMsg = sokMsg;
            this.dgShowMsg = dgShowMsg;
            this.dgRemoveConnection = dgRemoveConnection;

            this.threadMsg = new Thread(RecMsg);
            this.threadMsg.IsBackground = true;
            this.threadMsg.Start();
        }
예제 #3
0
 public MsgConnection(Socket sokMsg, DGShowMsg dgShow, DGCloseConn dgCloseConn)
 {
     this.sokMsg      = sokMsg;
     this.dgShow      = dgShow;
     this.dgCloseConn = dgCloseConn;
     //创建通信线程,负责调用通信套接字,来接收客户端消息。
     thrMsg = new Thread(ReceiveMsg);
     thrMsg.IsBackground = true;
     thrMsg.Start(this.sokMsg);
 }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sokMsg">通信套接字</param>
        /// <param name="dgShowMsg">向主窗体文本框显示消息的方法委托</param>
        public ConnectionClient(Socket sokMsg, DGShowMsg dgShowMsg, DGShowMsg dgRemoveConnection)
        {
            this.sokMsg             = sokMsg;
            this.dgShowMsg          = dgShowMsg;
            this.dgRemoveConnection = dgRemoveConnection;

            this.threadMsg = new Thread(RecMsg);
            this.threadMsg.IsBackground = true;
            this.threadMsg.Start();
        }
예제 #5
0
        public Server(Socket sokMsg, DGShowMsg dgShow, DGCloseConn dgCloseConn, DGAnalysis dgAnalysis)
        {
            this.sokMsg      = sokMsg;
            this.dgShow      = dgShow;
            this.dgCloseConn = dgCloseConn;
            this.dgAnalysis  = dgAnalysis;

            // 创建通信线程,负责调用通信套接字,来接收客户端消息。
            thrMsg = new Thread(ReceiveMsg)
            {
                IsBackground = true
            };
            thrMsg.Start(this.sokMsg);
        }
예제 #6
0
        public HttpApplication(Socket newSocket, DGShowMsg dgShowMsg)
        {
            this.newSocket = newSocket;
            this.dgShowMsg = dgShowMsg;
            //接收客户端发送过来的数据.
            byte[] buffer = new byte[1024 * 1024 * 2];
            int    receiveLength;

            receiveLength = newSocket.Receive(buffer);//接收客户端发送过来的数据,返回的是实际接收的数据的长度。
            if (receiveLength > 0)
            {
                string     msg     = System.Text.Encoding.UTF8.GetString(buffer, 0, receiveLength);
                HttpRequst request = new HttpRequst(msg);
                ProcessReuest(request);
                dgShowMsg(msg);
            }
        }
예제 #7
0
        public HttpApplication(Socket newSocket, DGShowMsg dgShowMsg)
        {
            this.newSocket = newSocket;
            this.dgShowMsg = dgShowMsg;

            //接受客户端发送过来的数据
            byte[] buffer = new byte[1024 * 1024 * 2];
            int    receiveLength;

            //接受客户端发送过来的数据 返回数据世界的长度
            receiveLength = newSocket.Receive(buffer);

            if (receiveLength > 0)
            {
                string      msg     = Encoding.UTF8.GetString(buffer, 0, receiveLength);
                HttpRequest request = new HttpRequest(msg);
                ProcessRequest(request);
                dgShowMsg(msg);
            }
        }
예제 #8
0
        //构造方法,在该类创建的时候,执行
        public HttpApplication(Socket socket, DGShowMsg dgShowMsg)
        {
            //01_获取到socket和委托(签名一样的方法)
            this.socket    = socket;
            this.dgShowMsg = dgShowMsg;

            //02_接收客户端发送过来的数据
            byte[] buffer        = new byte[1024 * 1024 * 2]; //定义一个字节数组
            int    receiveLength = socket.Receive(buffer);    //接收客户端发送过来的数据,返回的是实际接收的数据的长度。

            //03_判断接收到的数据是否有值
            if (receiveLength > 0)
            {
                //此时拿到了发送的socket请求信息
                string msg = System.Text.Encoding.UTF8.GetString(buffer, 0, receiveLength);//将二进制信息解析成string字符串
                //对请求报文进行处理,此时可以得到要访问文件的名称
                HttpRequst requst = new HttpRequst(msg);
                //此时会返回响应头  和  响应体
                ProcessRequest(requst);

                dgShowMsg(msg);
            }
        }