在全新的MacBook Air上使用Flex Builder 4.5,在localhost上运行rails。使用curl,读取服务器的响应时间约为200-300ms。当我使用HTTPService时,从send()到收到的结果在1-5秒之间,从服务器接收的XML行少于10行。如果我使用浏览器呈现URL,它会匹配curl,即它是即时的,我不等待XML呈现。
调试/非调试模式的数量相同。在创建完成后调用HTTPService,因此GUI完成。收到数据后,我的其余算法在应用程序中完成了20ms。
这次是预期的,还是我做错了什么,或者配置错误了什么?
答案 0 :(得分: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's algorithm。
答案 1 :(得分:0)
要扩展sarnold的答案,您需要做的是添加以下行:
<socket-tcp-no-delay-enabled>true</socket-tcp-no-delay-enabled>