AS3 - how to shutdown tcp connection?

梦想与她 提交于 2019-12-08 04:36:20

问题


AS3 program keeps connection open though URLLoader instance is closed using close() method. Is any way to shutdown connection immediately once data is loaded?

Checking connection status from commandline using netstat command, it is showing as Eshtablished.

Please suggest.


回答1:


URLLoader is a HTTP wrapper. You have to use HTTP stuff to get it done. In order to close the connection you would have to send the Connection: close HTTP header along with the webserver response. (Note that the default for most webservers is Connection: Keep-Alive, and it is the behaviour you are seeing).

In order to send it from Flash to the server, you would have to have the local-trusted or AIR application sandbox. This is not possible when running in a browser (on the internet).

From the docs:

In Flash Player and in Adobe AIR content outside of the application security sandbox, the following request headers cannot be used, and the restricted terms are not case-sensitive (for example, Get, get, and GET are all not allowed). Also, hyphenated terms apply if an underscore character is used (for example, both Content-Length and Content_Length are not allowed):

Accept-Charset, Accept-Encoding, Accept-Ranges, Age, Allow, Allowed, Authorization, Charge-To, Connect, Connection, Content-Length, Content-Location, Content-Range, Cookie, Date, Delete, ETag, Expect, Get, Head, Host, If-Modified-Since, Keep-Alive, Last-Modified, Location, Max-Forwards, Options, Origin, Post, Proxy-Authenticate, Proxy-Authorization, Proxy-Connection, Public, Put, Range, Referer, Request-Range, Retry-After, Server, TE, Trace, Trailer, Transfer-Encoding, Upgrade, URI, User-Agent, Vary, Via, Warning, WWW-Authenticate, x-flash-version.



来源:https://stackoverflow.com/questions/12751136/as3-how-to-shutdown-tcp-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!