Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.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#_.net_Mono_Pipelining - Fatal编程技术网

如何使用C#处理流水线请求?

如何使用C#处理流水线请求?,c#,.net,mono,pipelining,C#,.net,Mono,Pipelining,我需要在我的C#Mono(Linux上的Mono版本3.12.1)服务器中处理管道请求,但我注意到管道中的第二个请求总是被忽略 下面是我的netcat命令,用于测试管道: nc -v localhost 5000 < httppipe.txt 我很有信心我的netcat方法可以工作,因为我在Java服务器上成功地测试了它。(意思是我看到了两个回答) 在我的C#服务器中,我尝试了GetResult和GetResultAsync。GetResultAsync的代码基本上是从MSDN示例中提

我需要在我的C#Mono(Linux上的Mono版本3.12.1)服务器中处理管道请求,但我注意到管道中的第二个请求总是被忽略

下面是我的netcat命令,用于测试管道:

nc -v localhost 5000 < httppipe.txt 
我很有信心我的netcat方法可以工作,因为我在Java服务器上成功地测试了它。(意思是我看到了两个回答)

在我的C#服务器中,我尝试了GetResult和GetResultAsync。GetResultAsync的代码基本上是从MSDN示例中提取出来的。看起来是这样的:

this.Listener = new HttpListener();
this.Listener.Prefixes.Add(uriPrefix);
this.Listener.BeginGetContext(new AsyncCallback(ListenerCallback),this.Listener);

public static void ListenerCallback(IAsyncResult result)
        {
            HttpListener listener = (HttpListener) result.AsyncState;
            // Call EndGetContext to complete the asynchronous operation.
            HttpListenerContext context = listener.EndGetContext(result);
            listener.BeginGetContext(new AsyncCallback(ListenerCallback), listener);
            HttpListenerRequest request = context.Request;
            // Obtain a response object.
            HttpListenerResponse response = context.Response;
            // Construct a response. 
            string responseString = "<HTML><BODY> Hello world!</BODY></HTML>";
            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
            // Get a response stream and write the response to it.
            response.ContentLength64 = buffer.Length;
            System.IO.Stream output = response.OutputStream;
            output.Write(buffer,0,buffer.Length);
            // You must close the output stream.
            output.Close(); 
        }
this.Listener=new-HttpListener();
this.Listener.Prefixes.Add(uriPrefix);
this.Listener.BeginGetContext(新的AsyncCallback(ListenerCallback),this.Listener);
公共静态void ListenerCallback(IAsyncResult结果)
{
HttpListener=(HttpListener)result.AsyncState;
//调用EndGetContext以完成异步操作。
HttpListenerContext=listener.EndGetContext(结果);
BeginGetContext(新的AsyncCallback(ListenerCallback),listener);
HttpListenerRequest=context.request;
//获取一个响应对象。
HttpListenerResponse=context.response;
//构建一个响应。
string responseString=“你好,世界!”;
byte[]buffer=System.Text.Encoding.UTF8.GetBytes(responseString);
//获取响应流并将响应写入其中。
response.ContentLength64=buffer.Length;
System.IO.Stream输出=response.OutputStream;
输出.写入(缓冲区,0,缓冲区.长度);
//必须关闭输出流。
output.Close();
}
编辑:在Linux上的Mono4.0上也尝试过,但没有效果

this.Listener = new HttpListener();
this.Listener.Prefixes.Add(uriPrefix);
this.Listener.BeginGetContext(new AsyncCallback(ListenerCallback),this.Listener);

public static void ListenerCallback(IAsyncResult result)
        {
            HttpListener listener = (HttpListener) result.AsyncState;
            // Call EndGetContext to complete the asynchronous operation.
            HttpListenerContext context = listener.EndGetContext(result);
            listener.BeginGetContext(new AsyncCallback(ListenerCallback), listener);
            HttpListenerRequest request = context.Request;
            // Obtain a response object.
            HttpListenerResponse response = context.Response;
            // Construct a response. 
            string responseString = "<HTML><BODY> Hello world!</BODY></HTML>";
            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
            // Get a response stream and write the response to it.
            response.ContentLength64 = buffer.Length;
            System.IO.Stream output = response.OutputStream;
            output.Write(buffer,0,buffer.Length);
            // You must close the output stream.
            output.Close(); 
        }