与远程互联网网站的多个连接

发布于 2024-11-28 19:18:16 字数 777 浏览 0 评论 0原文

作为实验的一部分,我尝试让 32 个并发连接连接到互联网上的网站并下载与连接的每个 url 关联的 html 页面,但在其中大约 10 到 20 个连接上出现以下异常

 System.IO.IOException: Unable to read data from the transport connection: 
    An existing    connection was forcibly closed by the remote host. --->
    System.Net.Sockets.SocketException: An existing connection was forcibly 
    closed by the remote host at System.Net.Sockets.Socket.Receive(Byte[] buffer, 
    Int32 offset, Int32 size, SocketFlags socketFlags)
    at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.IO.StreamReader.ReadBuffer()
   at System.IO.StreamReader.ReadToEnd()

As part of an experiment, I am trying to have 32 concurrent connection connect to a website on the internet and download the html page associated to each url of the connection but I am getting the following exception on about 10 to 20 of those connections

 System.IO.IOException: Unable to read data from the transport connection: 
    An existing    connection was forcibly closed by the remote host. --->
    System.Net.Sockets.SocketException: An existing connection was forcibly 
    closed by the remote host at System.Net.Sockets.Socket.Receive(Byte[] buffer, 
    Int32 offset, Int32 size, SocketFlags socketFlags)
    at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.IO.StreamReader.ReadBuffer()
   at System.IO.StreamReader.ReadToEnd()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

盗琴音 2024-12-05 19:18:16
  1. 服务器可以限制您的X个连接
  2. ,因为您只能拥有CPU核心数量的真正并发性,之后首先执行的连接是随机的,
  3. 可以是您列出的任何步骤,
  4. 服务器希望可以由尽可能多的唯一访问人(IP地址)尽可能
  5. 不同的IP地址,这需要另一个物理连接或通过代理服务器管道一些连接,如果两者都不可能,则无法绕过它
  1. the server can limit you to X connections
  2. because you can only have true concurrency up to the number of cores in your cpu, after that it's random what connection is executed first
  3. can be any step you listed
  4. the server wants to be accessable by as many unique persons (IP adresses) as possible
  5. different IP adresses, which needs another physical connection or piping some connections through a proxy server, if neither is possible you can't get around it
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文