예제 #1
0
        /// <summary>
        /// 向服务端发送多个二进制信息
        /// </summary>
        /// <param name="AlgorithmClassName"></param>
        /// <param name="byteFile"></param>
        /// <returns></returns>
        public List <string> RequestAlgorithm(string AlgorithmClassName, params List <byte>[] byteMsgs)
        {
            //发起连接
            Socket socket = Connecter.Connect(this.cfger.PORT);

            if (socket == null)
            {
                return(null);
            }

            //发送调用函数信息
            List <byte[]> byteArrList = new List <byte[]>();

            foreach (List <byte> byteList in byteMsgs)
            {
                byteArrList.Add(byteList.ToArray());
            }
            socket.Send(Sender.PreTreatment(cfger.SPLIT_STR, cfger.TRAILER, AlgorithmClassName, byteArrList));

            //循环,接收返回结果
            List <string> solve = Receiver.Receive(socket, cfger.SPLIT_STR, cfger.TRAILER, cfger.BUFSIZE, cfger.MAX_BLOCK_SIZE);

            //关闭连接
            socket.Close();

            return(solve);
        }
예제 #2
0
        /// <summary>
        /// 外界可以用这个函数来想方法服务器发送请求,返回字符串作为结果
        /// </summary>
        /// <param name="AlgorithmClassName"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public List <string> RequestAlgorithm(string AlgorithmClassName, params string[] parameters)
        {
            //发起连接
            Socket socket = Connecter.Connect(this.cfger.PORT);

            if (socket == null)
            {
                return(null);
            }

            // 发送调用函数信息
            socket.Send(Sender.PreTreatment(cfger.SPLIT_STR, cfger.TRAILER, AlgorithmClassName, parameters));

            //循环,接收返回结果
            List <string> solve = Receiver.Receive(socket, cfger.SPLIT_STR, cfger.TRAILER, cfger.BUFSIZE, cfger.MAX_BLOCK_SIZE);

            //关闭连接
            socket.Close();

            return(solve);
        }