Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/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
监视Internet输入/输出请求并对其进行更改(c#)_C#_Sockets - Fatal编程技术网

监视Internet输入/输出请求并对其进行更改(c#)

监视Internet输入/输出请求并对其进行更改(c#),c#,sockets,C#,Sockets,我想监控从所有浏览器和其他应用程序发送的所有internet请求/响应,并对其进行更改。 我测试的一些方法: // Create a listener. HttpListener listener = new HttpListener(); // Add the prefixes. listener.Prefixes.Add("http://+:80/"); //hamid was *:80 listene

我想监控从所有浏览器和其他应用程序发送的所有internet请求/响应,并对其进行更改。 我测试的一些方法:

            // Create a listener.
        HttpListener listener = new HttpListener();

        // Add the prefixes.
        listener.Prefixes.Add("http://+:80/"); //hamid was *:80
        listener.Start();
        textBox3.Text = "listening...";//Console.WriteLine("Listening...");
        // Note: The GetContext method blocks while waiting for a request.
        HttpListenerContext context = listener.GetContext();
        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();
        listener.Stop();
//创建一个侦听器。
HttpListener=新的HttpListener();
//添加前缀。
Add(“http://+:80/”//哈米德是*:80
listener.Start();
textBox3.Text=“正在听…”//Console.WriteLine(“监听…”);
//注意:GetContext方法在等待请求时阻塞。
HttpListenerContext=listener.GetContext();
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();
listener.Stop();

假设您的所有其他应用程序都像浏览器一样支持代理,一个好的选择可能是使用并创建一个代理服务器,所有请求都通过该服务器传递


无任何代理设置,或仅使用套接字编程(如iPig)更改浏览器而不使用任何代理设置,或仅使用套接字编程(如iPig)更改浏览器