Wednesday, March 30, 2011
Adobe Flash
Adobe Flash (formerly Macromedia Flash) is a multimedia platform used to add animation, video, and interactivity to web pages. Flash is frequently used for advertisements and games. More recently, it has been positioned as a tool for "Rich Internet Applications" ("RIAs").
Software packages for production of two-dimensional animation include:
- This list is incomplete
Monday, March 21, 2011
JDBC
Getting Started with JDBC
1. Make the JDBC classes available to your Java program using:
- import java.sql.*;
2. Load the driver for the database system using:
- Class.forName( "<driverName>" );
3. Establish a connection to the database using :
- Connection con= DriverManager.getConnection( "<url>,<user>,<password>" );
Now we have a connection object called con which we can use to create statements. There are 2 methods to create statements:
- a) createStatement() returns a Statement object
- b) prepareStatement(Q) where Q is a SQL query passed as a string argument, returns a preparedStatement object
There are 4 methods that execute SQL statements.
- a) executeQuery(Q) takes a statement Q and is applied to a Statement object. This method returns a ResultSet object, which is the set of tuples produced by the query Q
- b) executeQuery() is applied to a preparedStatement object. This method also returns a ResultSet object.
- c) excuteUpdate(U) takes a nonquery statement U and, when applied to a statement object, executes U.
- d) executeUpdate() is applied to a preparedStatement object. The SQL statement associated with the prepared statement is executed.
Examples
The method
Class.forName(String)
is used to load the JDBC driver class. The line below causes the JDBC driver from some jdbc vendor to be loaded into the application. (Some JVMs also require the class to be instantiated with .newInstance()
.)Class.forName( "com.somejdbcvendor.TheirJdbcDriver" );
In JDBC 4.0, it's no longer necessary to explicitly load JDBC drivers using Class.forName(). See JDBC 4.0 Enhancements in Java SE 6.
When a
Driver
class is loaded, it creates an instance of itself and registers it with the DriverManager
. This can be done by including the needed code in the driver class's static
block. e.g. DriverManager.registerDriver(Driver driver)
Now when a connection is needed, one of the
DriverManager.getConnection()
methods is used to create a JDBC connection.Connection conn = DriverManager.getConnection(
"jdbc:somejdbcvendor:other data needed by some jdbc vendor",
"myLogin",
"myPassword" );
try {
/* you use the connection here */
} finally {
//It's important to close the connection when you are done with it
try { conn.close(); } catch (Throwable ignore) { /* Propagate the original exception
instead of this one that you may want just logged */ }
}
The URL used is dependent upon the particular JDBC driver. It will always begin with the "jdbc:" protocol, but the rest is up to the particular vendor. Once a connection is established, a statement must be created.
Statement stmt = conn.createStatement();
try {
stmt.executeUpdate( "INSERT INTO MyTable( name ) VALUES ( 'my name' ) " );
} finally {
//It's important to close the statement when you are done with it
try { stmt.close(); } catch (Throwable ignore) { /* Propagate the original exception
instead of this one that you may want just logged */ }
}
Note that Connections, Statements, and ResultSets often tie up operating system resources such as sockets or file descriptors. In the case of Connections to remote database servers, further resources are tied up on the server, e.g., cursors for currently open ResultSets. It is vital to
close()
any JDBC object as soon as it has played its part; garbage collection should not be relied upon. Forgetting to close()
things properly results in spurious errors and misbehaviour. The above try-finally construct is a recommended code pattern to use with JDBC objects.Data is retrieved from the database using a database query mechanism. The example below shows creating a statement and executing a query.
Statement stmt = conn.createStatement();
try {
ResultSet rs = stmt.executeQuery( "SELECT * FROM MyTable" );
try {
while ( rs.next() ) {
int numColumns = rs.getMetaData().getColumnCount();
for ( int i = 1 ; i <= numColumns ; i++ ) {
// Column numbers start at 1.
// Also there are many methods on the result set to return
// the column as a particular type. Refer to the Sun documentation
// for the list of valid conversions.
System.out.println( "COLUMN " + i + " = " + rs.getObject(i) );
}
}
} finally {
try { rs.close(); } catch (Throwable ignore) { /* Propagate the original exception
instead of this one that you may want just logged */ }
}
} finally {
try { stmt.close(); } catch (Throwable ignore) { /* Propagate the original exception
instead of this one that you may want just logged */ }
}
Typically, however, it would be rare for a seasoned Java programmer to code in such a fashion. The usual practice would be to abstract the database logic into an entirely different class and to pass preprocessed strings (perhaps derived themselves from a further abstracted class) containing SQL statements and the connection to the required methods. Abstracting the data model from the application code makes it more likely that changes to the application and data model can be made independently.
An example of a
PreparedStatement
query, using conn
and class from first example.PreparedStatement ps =
conn.prepareStatement( "SELECT i.*, j.* FROM Omega i, Zappa j WHERE i.name = ? AND j.num = ?" );
try {
// In the SQL statement being prepared, each question mark is a placeholder
// that must be replaced with a value you provide through a "set" method invocation.
// The following two method calls replace the two placeholders; the first is
// replaced by a string value, and the second by an integer value.
ps.setString(1, "Poor Yorick");
ps.setInt(2, 8008);
// The ResultSet, rs, conveys the result of executing the SQL statement.
// Each time you call rs.next(), an internal row pointer, or cursor,
// is advanced to the next row of the result. The cursor initially is
// positioned before the first row.
ResultSet rs = ps.executeQuery();
try {
while ( rs.next() ) {
int numColumns = rs.getMetaData().getColumnCount();
for ( int i = 1 ; i <= numColumns ; i++ ) {
// Column numbers start at 1.
// Also there are many methods on the result set to return
// the column as a particular type. Refer to the Sun documentation
// for the list of valid conversions.
System.out.println( "COLUMN " + i + " = " + rs.getObject(i) );
} // for
} // while
} finally {
try { rs.close(); } catch (Throwable ignore) { /* Propagate the original exception
instead of this one that you may want just logged */ }
}
} finally {
try { ps.close(); } catch (Throwable ignore) { /* Propagate the original exception
instead of this one that you may want just logged */ }
} // try
If a database operation fails, JDBC raises an
SQLException
. There is typically very little one can do to recover from such an error, apart from logging it with as much detail as possible. It is recommended that the SQLException be translated into an application domain exception (an unchecked one) that eventually results in a transaction rollback and a notification to the user.An example of a database transaction:
boolean autoCommitDefault = conn.getAutoCommit();
try {
conn.setAutoCommit(false);
/* You execute statements against conn here transactionally */
conn.commit();
} catch (Throwable e) {
try { conn.rollback(); } catch (Throwable ignore) {}
throw e;
} finally {
try { conn.setAutoCommit(autoCommitDefault); } catch (Throwable ignore) {}
}
Here are examples of host database types which Java can convert to with a function.
Oracle Datatype | setXXX() |
---|---|
CHAR | setString() |
VARCHAR2 | setString() |
NUMBER | setBigDecimal() |
setBoolean() | |
setByte() | |
setShort() | |
setInt() | |
setLong() | |
setFloat() | |
setDouble() | |
INTEGER | setInt() |
FLOAT | setDouble() |
CLOB | setClob() |
BLOB | setBlob() |
RAW | setBytes() |
LONGRAW | setBytes() |
DATE | setDate() |
setTime() | |
setTimestamp() |
Sunday, March 20, 2011
GREAT QUOTATIONS BY FREEDOM FIGHTER BHAGAT SINGH
- "The aim of life is no more to control the mind, but to develop it harmoniously; not to achieve salvation here after, but to make the best use of it here below; and not to realise truth, beauty and good only in contemplation, but also in the actual experience of daily life; social progress depends not upon the ennoblement of the few but on the enrichment of democracy; universal brotherhood can be achieved only when there is an equality of opportunity - of opportunity in the social, political and individual life." — from Bhagat Singh's prison diary "Inquilab Zindabad" (Long live the revolution)
Saturday, March 19, 2011
LIFE
Life is a characteristic that distinguishes objects that have signaling and self-sustaining processes (i. e., living organisms) from those that do not, either because such functions have ceased (death), or else because they lack such functions and are classified asinanimate Biology is the science concerned with the study of life.
Living organisms undergo metabolism, maintain homeostasis, possess a capacity to grow, respond to stimuli, reproduce and, through natural selection, adapt to their environment in successive generations. More complex living organisms can communicate through various means. A diverse array of living organisms (life forms) can be found in the biosphere on Earth, and the properties common to these organisms—plants, animals, fungi, protists,archaea, and bacteria—are a carbon- and water-based cellular form with complex organization and heritable genetic information.
In philosophy and religion, the conception of life and its nature varies. Both offer interpretations as to how life relates to existence and consciousness, and both touch on many related issues, including life stance, purpose, conception of a god or gods, a soul or an after life.
love means
Love is an emotion of strong affection and personal attachment In philosophical context, love is a virtue representing all of human kindness, compassion, and affection. Love is central to many religions, as in the Christian phrase, "God is love" or Agape in the Canonical gospels Love may also be described as actions towards others (or oneself) based on compassion. Or as actions towards others based on affection.
In English, the word love can refer to a variety of different feelings, states, and attitudes, ranging from generic pleasure ("I loved that meal") to intense interpersonal attraction ("I love my partner"). "Love" can also refer specifically to the passionate desire and intimacy of romantic love, to the sexual love of eros (cf. Greek words for love), to the emotional closeness of familial love, or to the platonic love that defines friendship, to the profound oneness or devotion of religious love. This diversity of uses and meanings, combined with the complexity of the feelings involved, makes love unusually difficult to consistently define, even compared to other emotional states.
Love in its various forms acts as a major facilitator of interpersonal relationships and, owing to its central psychological importance, is one of the most common themes in the creative arts.
Science defines what could be understood as love as an evolved state of the survival instinct, primarily used to keep human beings together against menaces and to facilitate the continuation of the species through reproduction
Home Video Editing
Like many other technologies, the cost of video editing has declined by an order of magnitude or more. The 2" Quadraplex system cost so much that many television production facilities could only afford a single unit and editing was a highly involved process requiring special training. In contrast, nearly any home computer sold since the year 2000 has the speed and storage capacity to digitize and edit standard definition video. The two major retail operating systems include basic video editing software - Apple's iMovie and Microsoft's Windows Movie Maker.
There are also more advanced commercial products such as AVS Video Editor, CyberLink Power Director, Adobe Premiere Elements, AVID Express DV, CyberLink PowerDirector, Final Cut Express, Sony Vegas, Pinnacle Studio, Ulead VideoStudio, Roxio Easy Media Creator, and muvee autoProducer.
Additionally, there are free opensource video-editing programs. These include Kdenlive, PiTiVi, Kino, Openshot and Cinelerra.
Video editing
Video editing is the process of editing segments of motion video footage, special effects and sound recordings. Motion picture film editing is a predecessor to video editing and, in several ways, video editing simulates motion picture film editing, in theory and the use of non-linear and linear editing systems. Using video or film, a director can communicate non-fictional and fictional events. The goals of editing is to manipulate these events for better or for worse communication. It is a visual art.
Early video recorders were so expensive, and the quality degradation caused by copying was so great, that 2 inch Quadruplex videotape was edited by visualizing the recorded track with ferrofluid and cutting with a razor blade or guillotine cutter and splicing with tape. Improvements in quality and economy, and the invention of the flying erase head, allowed new video and audio material to be recorded over the material already recorded on an existing tape. This technique was referred to as linear editing. If a scene closer to the beginning of the videotape needed to be changed in length, all later scenes would need to be recorded onto the tape again. In addition, sources could be played back simultaneously through a vision mixer to create more complex transitions between scenes.
There was a transitional analog period using multiple source VCRs or LaserDisc players, but modern non-linear editing systems use video digitally captured onto a hard drive from an analog or digital video source. Content is ingested and recorded natively in the appropriate codec which will be used by software such as Sony Vegas, CyberLink Power Director, Avid's Media Composer and Xpress Pro, Apple's Final Cut Pro, and Adobe's Premiere to manipulate the captured footage. High definition video is becoming more popular and can be readily edited using the same software along with related motion graphics programs. Clips are arranged on a timeline, music tracks and titles are added, effects can be created, and the finished program is "rendered" into a finished video. The video may then be distributed in a variety of ways including DVD, web streaming, Quicktime Movies, iPod, CD-ROM, or videotape.
Friday, March 18, 2011
Thursday, March 17, 2011
A Web Application
A web application
an application that is accessed over a network such as the Internet or an intranet. The term may also mean a computer software application that is hosted in a browser-controlled environment (e.g. a Java applet) or coded in a browser-supported language (such as JavaScript, combined with a browser-rendered markup language like HTML) and reliant on a common web browser to render the application executable.
an application that is accessed over a network such as the Internet or an intranet. The term may also mean a computer software application that is hosted in a browser-controlled environment (e.g. a Java applet) or coded in a browser-supported language (such as JavaScript, combined with a browser-rendered markup language like HTML) and reliant on a common web browser to render the application executable.
Web applications are popular due to the ubiquity of web browsers, and the convenience of using a web browser as a client, sometimes called a thin client. The ability to update and maintain web applications without distributing and installing software on potentially thousands of client computers is a key reason for their popularity, as is the inherent support for cross-platform compatibility. Common web applications include webmail, online retail sales, online auctions, wikis and many other functions.
Applications
Browser applications typically include simple office software (word processors, online spreadsheets, and presentation tools), with Google Docs being the most notable example, and can also include more advanced applications such as project management, computer-aided design, video editing and point-of-sale.
Java Server Pages
JSP(java server pages)
JSPs are compiled into servlets by a JSP compiler. The compiler either generates a servlet in Java code that is then compiled by the Java compiler, or it may compile the servlet to byte code which is directly executable. JSPs can alen to reload changes.
JSPs are compiled into servlets by a JSP compiler. The compiler either generates a servlet in Java code that is then compiled by the Java compiler, or it may compile the servlet to byte code which is directly executable. JSPs can alen to reload changes.
Regardless of whether the JSP compiler generates Java source code for a servlet or emits the byte code directly, it is helpful to understand how the JSP compiler transforms the page into a Java servlet. For example, consider the following input JSP and its resulting generated Java Servlet.
Input JSP
<%@ page errorPage="myerror.jsp" %> <%@ page import="com.foo.bar" %> <html> <head> <%! int serverInstanceVariable = 1;%> <% int localStackBasedVariable = 1; %> <table> <tr><td><%= toStringOrBlank( "expanded inline data " + 1 ) %></td></tr>
Resulting servlet
package jsp_servlet; import java.util.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import com.foo.bar; // Imported as a result of <%@ page import="com.foo.bar" %> import … class _myservlet implements javax.servlet.Servlet, javax.servlet.jsp.HttpJspPage { // Inserted as a // result of <%! int serverInstanceVariable = 1;%> int serverInstanceVariable = 1; … public void _jspService( javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response ) throws javax.servlet.ServletException, java.io.IOException { javax.servlet.ServletConfig config = …; // Get the servlet config Object page = this; PageContext pageContext = …; // Get the page context for this request javax.servlet.jsp.JspWriter out = pageContext.getOut(); HttpSession session = request.getSession( true ); try { out.print( "<html>\r\n" ); out.print( "<head>\r\n" ); … // From <% int localStackBasedVariable = 1; %> int localStackBasedVariable = 1; … out.print( "<table>\r\n" ); out.print( " <tr><td>" ); // From <%= toStringOrBlank( "expanded inline data " + 1 ) %> out.print( toStringOrBlank( "expanded inline data " + 1 ) ); out.print( " </td></tr>\r\n" ); … } catch ( Exception _exception ) { // Clean up and redirect to error page in <%@ page errorPage="myerror.jsp" %> } } }
JavaServer Pages compiler
A JavaServer Pages compiler, or JSP compiler, is a program that parses JavaServer Pages (JSPs), and transforms them into executable Java Servlets. A program of this type is usually embedded into an application server and run automatically the first time a JSP is accessed, but pages may also be precompiled for better performance, or compiled as a part of the build process to test for errors.
Most JSP containers support configuring how often the container checks JSP file timestamps to see if the page has changed. Typically, this timestamp would be set to a short interval (perhaps seconds) during software development, and a longer interval (perhaps minutes, or even never) for a deployed Web application.
Website controls (cross-domain policy files) ,Preloading policy files And Connecting to sockets
To make data from a web server available to SWF files from other domains, you can create a cross-domain policy file
on your server. A cross-domain policy file is an XML file that provides a way for the server to indicate that its data
and documents are available to SWF files served from certain domains or from all domains. Any SWF file that is
served from a domain specified by the server’s policy file is permitted to access data or assets from that server.
Cross-domain policy files affect access to a number of assets, including the following:
• Data in bitmaps, sounds, and videos
• Loading XML and text files
• Access to socket and XML socket connections
• Importing SWF files from other security domains into the security domain of the loading SWF file
Full details are provided in the rest of this chapter.
Policy file syntax
The following example shows a policy file that permits access to SWF files that originate from *.example.com,
www.friendOfExample.com and 192.0.34.166:
<?xml version="1.0"?>
<cross-domain-policy>
<allow-access-from domain="*.example.com" />
<allow-access-from domain="www.friendOfExample.com" />
<allow-access-from domain="192.0.34.166" />
</cross-domain-policy>
When a SWF file attempts to access data from another domain, Flash Player automatically attempts to load a policy
file from that domain. If the domain of the SWF file that is attempting to access the data is included in the policy file,
the data is automatically accessible.
By default, policy files must be named crossdomain.xml and must reside in the root directory of the server.
However, a SWF file can check for a different name or in a different directory location by calling the
Security.loadPolicyFile() method. A cross-domain policy file applies only to the directory from which it is
loaded and to its child directories. So a policy file in the root directory applies to the whole server, but a policy file
loaded from an arbitrary subdirectory applies only to that directory and its subdirectories.ADOBE FLEX 3
Developer Guide
541
A policy file affects access only to the particular server on which it resides. For example, a policy file located at
https://www.adobe.com:8080/crossdomain.xml will apply only to data- loading calls made to www.adobe.com over
HTTPS at port 8080.
A cross-domain policy file contains a single <cross-domain-policy> tag, which in turn contains zero or more
<allow-access-from> tags. Each <allow-access-from> tag contains an attribute, domain, which specifies either
an exact IP address, an exact domain, or a wildcard domain (any domain). Wildcard domains are indicated by either
a single asterisk (*), which matches all domains and all IP addresses, or an asterisk followed by a suffix, which
matches only those domains that end with the specified suffix. Suffixes must begin with a dot. However, wildcard
domains with suffixes can match domains that consist of only the suffix without the leading dot. For example,
foo.com is considered to be part of *.foo.com. Wildcards are not allowed in IP domain specifications.
If you specify an IP address, access is granted only to SWF files loaded from that IP address using IP syntax (for
example, http://65.57.83.12/flashmovie.swf), not those loaded using domain-name syntax. Flash Player does not
perform DNS resolution.
You can permit access to documents originating from any domain, as shown in the following example:
<?xml version="1.0"?>
<!-- http://www.foo.com/crossdomain.xml -->
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>
Each <allow-access-from> tag also has the optional secure attribute, which defaults to true. You can set the
attribute to false if your policy file is on an HTTPS server, and you want to allow SWF files on a non-HTTPS server
to load data from the HTTPS server.
Setting the secure attribute to false could compromise the security offered by HTTPS. In particular, setting this
attribute to false opens secure content to snooping and spoofing attacks. Adobe strongly recommends that you not
set the secure attribute to false.
If data to be loaded is on a HTTPS server, but the SWF file loading it is on an HTTP server, Adobe recommends that
you move the loading SWF file to an HTTPS server so that you can keep all copies of your secure data under the
protection of HTTPS. However, if you decide that you must keep the loading SWF file on an HTTP server, add the
secure="false" attribute to the <allow-access-from> tag, as shown in the following code:
<allow-access-from domain="www.example.com" secure="false" />
A policy file that contains no <allow-access-from> tags has the same effect as not having a policy on a server.
Socket policy files
ActionScript objects instantiate two different kinds of server connections: document-based server connections and
socket connections. ActionScript objects like Loader, Sound, URLLoader, and URLStream instantiate documentbased server connections, and these each load a file from a URL. ActionScript Socket and XMLSocket objects make
socket connections, which operate with streaming data, not loaded documents. Flash Player supports two kinds of
policy files: document-based policy files and socket policy files. Document-based connections require documentbased policy files, while socket connections require socket policy files.
Flash Player requires that a policy file be transmitted using the same kind of protocol that the attempted connection
wishes to use. For example, when you place a policy file on your HTTP server, SWF files from other domains are
allowed to load data from it as an HTTP server. However, by not providing a socket policy file at the same server,
you are forbidding SWF files from other domains to connect to the server at the socket level. The means by which a
socket policy file is retrieved must match the means of connecting.ADOBE FLEX 3
Developer Guide
542
A policy file served by a socket server has the same syntax as any other policy file, except that it must also specify the
ports to which it grants access. When a policy file comes from a port number that is less than 1024, it may grant
access to any ports; when a policy file comes from port 1024 or higher, it may only grant access to ports 1024 and
higher. The allowed ports are specified in a to-ports attribute in the <allow-access-from> tag. Single port
numbers, port ranges, and wildcards are accepted values.
Here is an example XMLSocket policy file:
<cross-domain-policy>
<allow-access-from domain="*" to-ports="507" />
<allow-access-from domain="*.example.com" to-ports="507,516" />
<allow-access-from domain="*.example2.com" to-ports="516-523" />
<allow-access-from domain="www.example2.com" to-ports="507,516-523" />
<allow-access-from domain="www.example3.com" to-ports="*" />
</cross-domain-policy>
When policy files were first introduced in Flash Player 6, there was no support for socket policy files. Connections
to socket servers were authorized by a policy file from the default location of the cross-domain policy file on an
HTTP server on port 80 of the same host as the socket server. To make it possible to preserve existing server arrangements, Flash Player 9 still supports this capability. However, Flash Player’s default is now to retrieve a socket policy
file on the same port as the socket connection. If you wish to use an HTTP-based policy file to authorize a socket
connection, you must explicitly request the HTTP policy file using code such as the following:
Security.loadPolicyFile("http://socketServerHost.com/crossdomain.xml")
In addition, in order to authorize socket connections, an HTTP policy file must come only from the default location
of the cross-domain policy file, and not from any other HTTP location. A policy file obtained from an HTTP server
implicitly authorizes socket access to all ports 1024 and above; any to-ports attributes in an HTTP policy file are
ignored.
Preloading policy files
Loading data from a server or connecting to a socket is an asynchronous operation, and Flash Player simply waits
for the cross-domain policy file to finish downloading before it begins the main operation. However, extracting pixel
data from images or extracting sample data from sounds is a synchronous operation—the cross-domain policy file
must load before you can extract data. When you load the media, you need to specify that it check for a cross-domain
policy file:
• When using the Loader.load() method, set the checkPolicyFile property of the context parameter, which
is a LoaderContext object.
• When embedding an image in a text field using the <img> tag, set the checkPolicyFile attribute of the <img>
tag to "true", as in the following: <img checkPolicyFile = "true" src = "example.jpg">.
• When using the Sound.load() method, set the checkPolicyFile property of the context parameter, which
is a SoundLoaderContext object.
• When using the NetStream class, set the checkPolicyFile property of the NetStream object.
When you set one of these parameters, Flash Player first checks for any policy files that it already has downloaded
for that domain. Then it considers any pending calls to the Security.loadPolicyFile() method to see if they are
in scope, and waits for those if they are. Then it looks for the cross-domain policy file in the default location on the
server.
Connecting to sockets
Cross-domain access to socket and XML socket connections is disabled by default. Also disabled by default is access
to socket connections in the same domain as the SWF file on ports lower than 1024. You can permit access to these
ports by serving a cross-domain policy file from any of the following locations:
• The same port as the main socket connection
• A different port
• An HTTP server on port 80 in the same domain as the socket server
If you serve the cross-domain policy file from same port as the main socket connection, or in a different port, you
enumerate permitted ports by using a to-ports attribute in the cross-domain policy file, as the following example
shows:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domainpolicy.dtd">ADOBE FLEX 3
<!-- 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 a socket policy file from the same port as a main socket connection, simply call the Socket.connect()
or XMLSocket.connect() method, and, if the specified domain is not the same as the domain of the calling SWF
file, Flash Player automatically attempts to retrieve a policy file from the same port as the main connection you are
attempting. To retrieve a socket policy file from a different port on the same server as your main connection, call the
Security.loadPolicyFile() method with the special "xmlsocket" syntax, as in the following:
Security.loadPolicyFile("xmlsocket://server.com:2525");
Call the Security.loadPolicyFile() method before calling the Socket.connect() or XMLSocket.connect()
method. Flash Player then waits until it has fulfilled your policy file request before deciding whether to allow your
main connection.
If you are implementing a socket server and you need to provide a socket policy file, decide whether you will provide
the policy file using the same port that accepts main connections, or using a different port. In either case, your server
must wait for the first transmission from your client before deciding whether to send a policy file or set up a main
connection. When Flash Player requests a policy file, it always transmits the following string as soon as a connection
is established:
<policy-file-request/>
Once the server receives this string, it can transmit the policy file. Do not expect to reuse the same connection for
both a policy file request and a main connection; you should close the connection after transmitting the policy file.
If you do not, Flash Player closes the policy file connection before reconnecting to set up the main connection
Subscribe to:
Posts (Atom)