Connect to socket

Source: Internet
Author: User

By default, Flash Player searches for the socket policy file from Port 843. Like a URL policy file, this file is called a "master policy file ".
When a policy file is first introduced in Flash Player 6, the socket policy file is not supported. The connection to the socket server is granted by a policy file in the default location
The default location is port 80 of the HTTP server of the host where the socket server is located. Flash Player 9 still supports this function, but Flash Player 10 does not
Yes. In Flash Player 10, only the socket policy file can authorize socket connection.
Similar to the URL policy file, the socket policy file supports meta-policy statements (used to specify the port that can provide the policy file ). However, the default socket policy file
The meta-policy is "all" instead of "Master-only ". That is, unless the master policy file specifies more restrictive settings, Flash Player assumes that any settings on the host
The socket policy file can be provided.
By default, access to sockets and XML socket connections are prohibited, even if the socket to be connected is in the same domain as the SWF file. You can
The socket policy file is provided anywhere to allow socket-level access:
• Port 843 (location of the Master policy file)
• The same port as the main socket connection
• Ports outside the main socket connection Port
By default, Flash Player searches for the socket policy file on the port where port 843 and the primary socket connection are located. If you want to provide socket policies from other ports
File, SWF file must call security. loadpolicyfile ().
The socket policy file has the same syntax as the URL policy file, but the former must also specify which ports to grant access permissions. If the socket policy file
If the policy file is from Port 1024 or higher, it can only grant access to any port.
Grant access permissions to higher ports. The allowed ports are specified in the to-ports attribute in the <allow-access-from> flag. Single Port Number, port range, and wildcard
All are allowed values.
The following is an example of a socket policy file:
<? XML version = "1.0"?>
<! Doctype cross-domain-Policy System "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<! -- Policy file for xmlsocket: // socks.mysite.com -->
<Cross-domain-Policy>
<Allow-access-from domain = "*" to-ports = "507"/>
<Allow-access-from domain = "* .example.com" to-ports = "507,516"/>
<Allow-access-from domain = "* .example.org" to-ports = "516-523"/>
<Allow-access-from domain = "adobe.com" to-ports = "507,516-523"/>
<Allow-access-from domain = "192.0.34.166" to-ports = "*"/>
</Cross-Domain-Policy>
To retrieve the socket policy file from Port 843 or the port on which the primary socket connection is located, call the socket. Connect () or xmlsocket. Connect () method.
Flash Player first checks whether the master policy file exists on port 843. If the Master policy file is found, Flash Player checks whether the file is contained on the target.
Disable the meta-Policy Statement of the socket policy file on the port. If access is not prohibited, flash player first searches for the appropriate allow-access-from language in the master policy file.
Sentence. If the Master policy file cannot be found, Flash Player searches for the socket policy file on the port where the master socket connection is located.
To retrieve the socket policy file from other locations, call the security. loadpolicyfile () method and use the special "xmlsocket" syntax.
Description:
Security. loadpolicyfile ("xmlsocket: // server.com: 2525 ");
Call the security. loadpolicyfile () method first, and then call the socket. Connect () or xmlsocket. Connect () method. Flash player will be waiting
After the policy file request is completed, determine whether to allow the master connection. However, if the policy file cannot be provided at the specified destination location
Loadpolicyfile () is invalid, even if a policy file exists at the location.
If you want to implement the socket server and provide the socket policy file, you should decide whether to use the same port that accepts the master connection to provide the policy file or use
The same port to provide the policy file. In either case, the server must wait until the client receives the first transmission before sending a response.
When Flash Player requests a policy file, it will always transmit the following strings after a connection is established:
<Policy-file-Request/>
After receiving this string, the server transfers the policy file. Requests from Flash Player are always terminated by NULL bytes, and responses from the server must also be
NULL bytes are terminated.
The program does not use the same connection for the policy file request and the master connection. Therefore, close the connection after the policy file is transferred. If you do not close the connection, flash player will
Close the policy file connection, and then reconnect to establish a master connection.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.