2

在全新的 MacBook Air 上使用 Flex Builder 4.5 和在 localhost 上运行的 rails。使用curl,一次读取服务器的响应时间在200-300ms左右。当我使用 HTTPService 时,从发送()到收到结果的时间在 1-5 秒之间,从服务器接收到的 XML 不到十行。如果我使用浏览器呈现 URL,它匹配 curl,即它是瞬时的,我不等待 XML 呈现。

调试/非调试模式的数字相同。创建完成后调用HTTPService,GUI就完成了。收到数据后,我的其余算法在应用程序中的完成时间不到 20 毫秒。

这个时间是预期的,还是我做错了什么,或者配置不正确?

4

2 回答 2

1

您所描述的听起来像是在发送请求之前HTTPService没有在其套接字上设置TCP_NODELAY套接字选项( )。setsockopt(3)从我的 Linux tcp(7)

  TCP_NODELAY
          If set, disable the Nagle algorithm.  This means that
          segments are always sent as soon as possible, even if
          there is only a small amount of data.  When not set,
          data is buffered until there is a sufficient amount to
          send out, thereby avoiding the frequent sending of
          small packets, which results in poor utilization of
          the network.  This option is overridden by TCP_CORK;
          however, setting this option forces an explicit flush
          of pending output, even if TCP_CORK is currently set.

也许您的平台有另一种方法,您可以要求为特定连接禁用Nagle 算法。

于 2011-11-07T05:11:30.147 回答
0

要扩展 sarnold 的答案,您需要做的是添加以下行:

<socket-tcp-no-delay-enabled>true</socket-tcp-no-delay-enabled>
于 2011-11-07T09:13:41.027 回答