Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 简单客户机-服务器应用程序_C#_Asp.net_Multithreading_Wcf_Client Server - Fatal编程技术网

C# 简单客户机-服务器应用程序

C# 简单客户机-服务器应用程序,c#,asp.net,multithreading,wcf,client-server,C#,Asp.net,Multithreading,Wcf,Client Server,具有以下体系结构:客户端(C#上的dll)在服务器(或Windows服务或Web服务)上发送一定数量的图像,在服务器上处理这些图像,然后服务器以处理结果的XML文件的形式发回响应 客户端只是一个没有接口和输入/输出的自动化应用程序 服务器。它使用多线程(使用ThreadPool)启动引擎来处理图像。因此,当引用一个新客户机时,服务器创建一个新线程,在该线程中进行处理,最后向用户发送一个回复(xml文件)。服务器上的负载不是很大3-20个并发连接 到目前为止,我无法理解什么是最适合我的交互架构。有

具有以下体系结构:客户端(C#上的dll)在服务器(或Windows服务或Web服务)上发送一定数量的图像,在服务器上处理这些图像,然后服务器以处理结果的XML文件的形式发回响应

客户端只是一个没有接口和输入/输出的自动化应用程序

服务器。它使用多线程(使用ThreadPool)启动引擎来处理图像。因此,当引用一个新客户机时,服务器创建一个新线程,在该线程中进行处理,最后向用户发送一个回复(xml文件)。服务器上的负载不是很大3-20个并发连接

到目前为止,我无法理解什么是最适合我的交互架构。有几种方法可以实现或在其上编写异步套接字服务器,可以使用WCF,也可以只编写ASP.NET应用程序并将其放到IIS上(对于此选项,我最倾向于使用)

哪种传输协议最适合使用?使用HTTP传输大量图片(然后可以向Web服务的方向移动),还是应该考虑TCP/IP(现在是WCF)


就这些

以下是一种单独发送的方式:

        Byte[] imgByte = null;
        System.IO.Stream strm;
        string imgfile = System.IO.Path.GetFileName(FileUpload1.FileName);
        string ext = System.IO.Path.GetExtension(FileUpload1.FileName);
        if (ext == ".jpg" | ext == ".jpeg" | ext == ".gif" | ext == ".png")
        {
            try
            {

                if (FileUpload1.HasFile && FileUpload1.PostedFile != null)
                {
                    int fileLen = FileUpload1.PostedFile.ContentLength;
                    HttpPostedFile File = FileUpload1.PostedFile;
                    StringBuilder sb = new StringBuilder();
                    imgByte = new Byte[fileLen];
                    strm = FileUpload1.FileContent;
                    strm.Read(imgByte, 0, fileLen);
                }
            }
            catch (Exception ex)
            {
                Label1.Text = "Stream: " + ex.ToString();
            }
            if (imgByte != null)
            {
                try
                {
                    string connStr = ConfigurationManager.ConnectionStrings["imgContext"].ConnectionString;
                    string cmdStr = "INSERT INTO [Table] (filename, image) VALUES (@filename, @image);";
                    using (SqlConnection conn = new SqlConnection(connStr))
                    {
                        using (SqlCommand cmd = new SqlCommand(cmdStr, conn))
                        {
                            conn.Open();
                            cmd.Parameters.AddWithValue("@filename", imgfile);
                            cmd.Parameters.AddWithValue("@image", imgByte);
                            cmd.ExecuteNonQuery();
                            conn.Close();
                            cmd.Dispose();
                            conn.Dispose();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Label2.Text = "sql: " + ex.ToString();
                }
            }

谁是最终用户?这是一个个人在网上还是一个应用程序?吞吐量要求是什么?聘请一名技术/解决方案架构师。研究WCF流媒体技术-在这种情况下,web服务应用程序更容易实现。TCP服务应用程序将需要传输协议实现,通常还需要windows服务应用程序。感谢重播。最终用户是应用程序,因此不需要接口。E1带宽要求非常低,同时将有大约10-20个连接。因此,据我所知,我应该使用WCF或ASP.NET。您可能希望将.Close和.Dispose语句放在Finally块中,而不是try块中。。。