<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>xrain's Weblog</title>
	<atom:link href="http://xrain.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://xrain.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Wed, 25 Nov 2009 07:12:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='xrain.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>xrain's Weblog</title>
		<link>http://xrain.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://xrain.wordpress.com/osd.xml" title="xrain&#039;s Weblog" />
	<atom:link rel='hub' href='http://xrain.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Những trường hợp nói nốt, tắt trong tiếng Anh</title>
		<link>http://xrain.wordpress.com/2008/05/10/nh%e1%bb%afng-tr%c6%b0%e1%bb%9dng-h%e1%bb%a3p-noi-n%e1%bb%91t-t%e1%ba%aft-trong-ti%e1%ba%bfng-anh/</link>
		<comments>http://xrain.wordpress.com/2008/05/10/nh%e1%bb%afng-tr%c6%b0%e1%bb%9dng-h%e1%bb%a3p-noi-n%e1%bb%91t-t%e1%ba%aft-trong-ti%e1%ba%bfng-anh/#comments</comments>
		<pubDate>Sat, 10 May 2008 06:52:05 +0000</pubDate>
		<dc:creator>xrain</dc:creator>
				<category><![CDATA[ENGLISH]]></category>

		<guid isPermaLink="false">http://xrain.wordpress.com/?p=16</guid>
		<description><![CDATA[- ’s not = it’s not - whatcher name ? = what’s your name ? - inni, wannit = isn’t it, wasn’t it - I dunno, stoo hard = I don’t know, it’s too hard - Cos = because - Course = of course - Probly = probably - Gonna = going to - Wanna [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=16&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div class="snap_preview">
<p class="MsoNormal">- ’s not = it’s not<br />
- whatcher name ? = what’s your name ?<br />
- inni, wannit = isn’t it, wasn’t it<br />
- I dunno, stoo hard = I don’t know, it’s too hard<br />
- Cos = because<br />
- Course = of course<br />
- Probly = probably<br />
- Gonna = going to<br />
- Wanna = want to<br />
- Wanna dance ? = do you want to dance?<br />
- I wanna go … = I want to go<br />
- How boutchu = how about you ?<br />
- How boutdit ? = how about it ?<br />
- Whatcha doing ? = what are you doing ?<br />
- Zit work ? = does it work ?<br />
- Zit ready yet ? = Is it ready yet</p>
<p class="MsoNormal">- Gotta = have to<br />
- kinda = kind of<br />
- outa = out of<br />
- woulda = would have<br />
- coulda = could have<br />
- shoulda = should have</p>
<p>Ở trên đây là một số từ thông dụng trong tiếng Anh. Ở bên tay trái là cách họ phát âm, còn ở bên tay phải là nghĩa của từ. Trong khi thi Toefl sẽ có rất nhiều câu hỏi để kiểm tra những từ này. Vì vậy làm quen những cách nói tắt này trong tiếng Anh (nói được và nghe được) cũng rất là quan trọng.</p>
<p>Nguồn: <a href="http://englishstudyforvms.wordpress.com/2007/06/03/nh%e1%bb%afng-tr%c6%b0%e1%bb%9dng-h%e1%bb%a3p-noi-n%e1%bb%91t-t%e1%ba%aft-trong-ti%e1%ba%bfng-anh/">link</a></p>
</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xrain.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xrain.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xrain.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xrain.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xrain.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xrain.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xrain.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xrain.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xrain.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xrain.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xrain.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xrain.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xrain.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xrain.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xrain.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xrain.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=16&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xrain.wordpress.com/2008/05/10/nh%e1%bb%afng-tr%c6%b0%e1%bb%9dng-h%e1%bb%a3p-noi-n%e1%bb%91t-t%e1%ba%aft-trong-ti%e1%ba%bfng-anh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c4777157d40cda711fb9d6630c4d8668?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xrain</media:title>
		</media:content>
	</item>
		<item>
		<title>Numerical Expressions: A guide to pronunciation</title>
		<link>http://xrain.wordpress.com/2008/05/10/numerical-expressions-a-guide-to-pronunciation/</link>
		<comments>http://xrain.wordpress.com/2008/05/10/numerical-expressions-a-guide-to-pronunciation/#comments</comments>
		<pubDate>Sat, 10 May 2008 03:44:38 +0000</pubDate>
		<dc:creator>xrain</dc:creator>
				<category><![CDATA[ENGLISH]]></category>

		<guid isPermaLink="false">http://xrain.wordpress.com/?p=15</guid>
		<description><![CDATA[<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=15&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://xrain.files.wordpress.com/2008/05/1.png"><img class="aligncenter size-full wp-image-13" src="http://xrain.files.wordpress.com/2008/05/1.png?w=468" alt=""   /></a><a href="http://xrain.files.wordpress.com/2008/05/2.png"><img class="aligncenter size-full wp-image-14" src="http://xrain.files.wordpress.com/2008/05/2.png?w=468" alt=""   /></a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xrain.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xrain.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xrain.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xrain.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xrain.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xrain.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xrain.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xrain.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xrain.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xrain.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xrain.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xrain.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xrain.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xrain.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xrain.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xrain.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=15&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xrain.wordpress.com/2008/05/10/numerical-expressions-a-guide-to-pronunciation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c4777157d40cda711fb9d6630c4d8668?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xrain</media:title>
		</media:content>

		<media:content url="http://xrain.files.wordpress.com/2008/05/1.png" medium="image" />

		<media:content url="http://xrain.files.wordpress.com/2008/05/2.png" medium="image" />
	</item>
		<item>
		<title>How Java Web Servers Work &#8211; part 3</title>
		<link>http://xrain.wordpress.com/2008/05/05/how-java-web-servers-work-part-3/</link>
		<comments>http://xrain.wordpress.com/2008/05/05/how-java-web-servers-work-part-3/#comments</comments>
		<pubDate>Mon, 05 May 2008 06:45:03 +0000</pubDate>
		<dc:creator>xrain</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[how java webservers work]]></category>

		<guid isPermaLink="false">http://xrain.wordpress.com/?p=12</guid>
		<description><![CDATA[The Request Class The Request class represents an HTTP request. An instance of this class is constructed by passing the InputStream object obtained from a Socket that handles the communication with the client. Call one of the read methods of the InputStream object to obtain the HTTP request raw data. The Request class has two [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=12&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span></p>
<h4>The <code>Request</code> Class</h4>
<p>The <code>Request</code> class represents an HTTP request. An instance of this class is constructed by passing the <code>InputStream</code> object obtained from a <code>Socket</code> that handles the communication with the client. Call one of the <code>read</code> methods of the <code>InputStream</code> object to obtain the HTTP request raw data.</p>
<p><span>The <code>Request</code> class has two public methods: <code>parse</code> and <code>getUri</code>. The <code>parse</code> method parses the raw data in the HTTP request. It doesn&#8217;t do much&#8211;the only information it makes available is the URI of the HTTP request, which it obtains by calling the private method <code>parseUri</code>. The <code>parseUri</code> method stores the URI in the <code>uri</code> variable. Invoke the public <code>getUri</code> method to return the URI of the HTTP request.</p>
<p>To understand how the <code>parse</code> and <code>parseUri</code> methods work, you need to know the structure of an HTTP request, which is defined in <a href="http://www.w3.org/Protocols/HTTP/1.1/rfc2616.pdf">RFC 2616</a>(.pdf).</p>
<p>An HTTP request contains three parts:</p>
<p><!-- sidebar begins --> <!-- don't move sidebars --> <!-- sidebar ends --></p>
<ul>
<li>Request line</li>
<li>Headers</li>
<li>Message body</li>
</ul>
<p>For now, we are only interested in the first part of the HTTP request, the request line. A request line begins with a method token, is followed by the request URI and the protocol version, and ends with carriage-return linefeed (CRLF) characters. Elements in the request line are separated by a space character. For instance, the request line for a request for the <em>index.html</em> file using the <code>GET</code> method is:</p>
<pre><code>GET /index.html HTTP/1.1</code></pre>
<p>The <code>parse</code> method reads the whole byte stream from the socket&#8217;s <code>InputStream</code> passed to the <code>Request</code> object, and stores the byte array in a buffer.  It then populates a <code>StringBuffer</code> object called <code>request</code> using the bytes in the <code>buffer</code> byte array, and passes the <code>String</code> representation of the <code>StringBuffer</code> to the <code>parseUri</code> method.</p>
<p>The <code>parse</code> method is given in Listing 1.2.</p>
<p><em>Listing 1.2. The <code>Request</code> class&#8217; <code>parse</code> method</em></p>
<pre><code>public void parse() {
    // Read a set of characters from the socket
    StringBuffer request = new StringBuffer(2048);
    int i;
    byte[] buffer = new byte[2048];

    try {
        i = input.read(buffer);
    }
    catch (IOException e) {
        e.printStackTrace();
        i = -1;
    }

    for (int j=0; j&lt;i; j++) {
        request.append((char) buffer[j]);
    }

    System.out.print(request.toString());
    uri   = parseUri(request.toString());
}</code></pre>
<p>The <code>parseUri</code> method then obtains the URI from the request line. Listing 1.3 shows the <code>parseUri</code> method.  The <code>parseUri</code> method searches for the first and the second spaces in the request and obtains the URI from there.</p>
<p><em>Listing 1.3. The <code>Request</code> class&#8217; <code>parseUri</code> method</em></p>
<pre><code>private String parseUri(String requestString) {
    int index1, index2;
    index1 = requestString.indexOf(' ');

    if (index1 != -1) {
        index2 = requestString.indexOf(' ', index1 + 1);
        if (index2 &gt; index1)
           return requestString.substring(index1 + 1, index2);
    }

    return null;
}</code></pre>
<h4>The <code>Response</code> Class</h4>
<p>The <code>Response</code> class represents an HTTP response. Its constructor accepts an <code>OutputStream</code> object, such as the following:</p>
<pre><code>public Response(OutputStream output) {
    this.output = output;
}</code></pre>
<p>A <code>Response</code> object is constructed by the <code>HttpServer</code> class&#8217; <code>await</code> method by passing the <code>OutputStream</code> object obtained from the socket.</p>
<p>The <code>Response</code> class has two public methods: <code>setRequest</code> and <code>sendStaticResource</code>. The <code>setRequest</code> method is used to pass a <code>Request</code> object to the <code>Response</code> object. It is as simple as the code in Listing 1.4.</p>
<p><em>Listing 1.4. The <code>Response</code> class&#8217; <code>setRequest</code> method</em></p>
<pre><code>public void setRequest(Request request) {
    this.request = request;
}</code></pre>
<p>The <code>sendStaticResource</code> method is used to send a static resource, such as an HTML file. Its implementation is given in Listing 1.5.</p>
<p><em>Listing 1.5. The <code>Response</code> class&#8217; <code>sendStaticResource</code> method</em></p>
<pre><code>public void sendStaticResource() throws IOException {
    byte[] bytes        = new byte[BUFFER_SIZE];
    FileInputStream fis = null;

    try {
        File file  = new File(HttpServer.WEB_ROOT, request.getUri());
        if (file.exists()) {
            fis    = new FileInputStream(file);
            int ch = fis.read(bytes, 0, BUFFER_SIZE);

            while (ch != -1) {
                output.write(bytes, 0, ch);
                ch = fis.read(bytes, 0, BUFFER_SIZE);
            }
        }
        else {
            // file not found
            String errorMessage = "HTTP/1.1 404 File Not Found\r\n" +
                "Content-Type: text/html\r\n" +
                "Content-Length: 23\r\n" +
                "\r\n" +
                "&lt;h1&gt;File Not Found&lt;/h1&gt;";
            output.write(errorMessage.getBytes());
        }
    }
    catch (Exception e) {
        // thrown if cannot instantiate a File object
        System.out.println(e.toString() );
    }
    finally {
        if (fis != null)
            fis.close();
    }
}</code></pre>
<p>The <code>sendStaticResource</code> method is very simple. It first instantiates the <code>java.io.File</code> class by passing the parent and child paths to the <code>File</code> class&#8217; constructor.</p>
<pre><code>File file = new File(HttpServer.WEB_ROOT, request.getUri());</code></pre>
<p>It then checks if the file exists. If it does, the <code>sendStaticResource</code> method constructs a <code>java.io.FileInputStream</code> object by passing the <code>File</code> object. It then invokes the <code>read</code> method of the <code>FileInputStream</code> and writes the byte array to the <code>OutputStream</code> output. Note that in this case, the content of the static resource is sent to the browser as raw data.</p>
<pre><code>if (file.exists()) {
    fis    = new FileInputStream(file);
    int ch = fis.read(bytes, 0, BUFFER_SIZE);

    while (ch != -1) {
        output.write(bytes, 0, ch);
        ch = fis.read(bytes, 0, BUFFER_SIZE);
    }
}</code></pre>
<p>If the file does not exist, the <code>sendStaticResource</code> method sends an error message to the browser.</p>
<pre><code>String errorMessage = "HTTP/1.1 404 File Not Found\r\n" +
    "Content-Type: text/html\r\n" +
    "Content-Length: 23\r\n" +
    "\r\n" +
    "&lt;h1&gt;File Not Found&lt;/h1&gt;";
output.write(errorMessage.getBytes());</code></pre>
<h3>Compiling and Running the Application</h3>
<p>To compile and run the application, you first need to extract the <a href="http://www.onjava.com/onjava/2003/04/23/examples/HowWebServersWork.zip">.zip</a> file containing the application for this article. The directory you extract the .zip file into is called the working directory and will have three sub-directories: <em>src/</em>, <em>classes/</em>, and <em>lib/</em>. To compile the application, type the following from the working directory:</p>
<pre><code>javac -d . src/ex01/pyrmont/*.java</code></pre>
<p>The <code>-d</code> option writes the results to the current, not the <em>src/</em>, directory.</p>
<p>To run the application, type the following from the working directory:</p>
<pre><code>java ex01.pyrmont.HttpServer</code></pre>
<p>To test the application, open your browser and type the following in the URL or Address box:</p>
<pre><code>http://localhost:8080/index.html</code></pre>
<p>You will see the <em>index.html</em> page displayed in your browser, as in Figure 1.</p>
<p><img src="http://www.onjava.com/onjava/2003/04/23/graphics/figure1.gif" alt="output from the web server" /><br />
<em>Figure 1. The output from the web server</em></p>
<p>On the console, you can see something like the following:</p>
<pre><code>GET /index.html HTTP/1.1
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)
Host: localhost:8080
Connection: Keep-Alive

GET /images/logo.gif HTTP/1.1
Accept: */*
Referer: http://localhost:8080/index.html
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)
Host: localhost:8080
Connection: Keep-Alive</code></pre>
<h3>Summary</h3>
<p>In this article, you have seen how a simple web server works. The application accompanying this article consists of only three classes and is not fully functional. Nevertheless, it serves as a good learning tool.</p>
<p><em> <a href="http://www.onjava.com/pub/au/136">Budi Kurniawan</a> is a senior J2EE architect and author. </em></p>
<p></span></p>
<p></span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xrain.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xrain.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xrain.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xrain.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xrain.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xrain.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xrain.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xrain.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xrain.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xrain.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xrain.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xrain.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xrain.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xrain.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xrain.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xrain.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=12&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xrain.wordpress.com/2008/05/05/how-java-web-servers-work-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c4777157d40cda711fb9d6630c4d8668?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xrain</media:title>
		</media:content>

		<media:content url="http://www.onjava.com/onjava/2003/04/23/graphics/figure1.gif" medium="image">
			<media:title type="html">output from the web server</media:title>
		</media:content>
	</item>
		<item>
		<title>How Java Web Servers Work &#8211; part 2</title>
		<link>http://xrain.wordpress.com/2008/05/05/how-java-web-servers-work-part-2/</link>
		<comments>http://xrain.wordpress.com/2008/05/05/how-java-web-servers-work-part-2/#comments</comments>
		<pubDate>Mon, 05 May 2008 06:43:45 +0000</pubDate>
		<dc:creator>xrain</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[how java webservers work]]></category>

		<guid isPermaLink="false">http://xrain.wordpress.com/?p=11</guid>
		<description><![CDATA[The ServerSocket Class The Socket class represents a &#8220;client&#8221; socket; a socket that you construct whenever you want to connect to a remote server application. If you want to implement a server application, such as an HTTP server or an FTP server, you need a different approach. This is because your server must stand by [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=11&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span></p>
<h3>The <code>ServerSocket</code> Class</h3>
<p>The <code>Socket</code> class represents a &#8220;client&#8221; socket; a socket that you construct whenever you want to connect to a remote server application.  If you want to implement a server application, such as an HTTP server or an FTP server, you need a different approach. This is because your server must stand by all the time, as it does not know when a client application will try to connect to it.</p>
<p><span>For this purpose, you need to use the <code>java.net.ServerSocket</code> class. This is an implementation of a server socket.  A server socket waits for a connection request from a client. Once it receives a connection request, it creates a <code>Socket</code> instance to handle the communication with the client.</p>
<p>To create a server socket, you need to use one of the four constructors the <code>ServerSocket</code> class provides. You need to specify the IP address and port number on which the server socket will listen. Typically, the IP address will be 127.0.0.1, meaning that the server socket will be listening on the local machine. The IP address the server socket is listening on is referred to as the binding address. Another important property of a server socket is its backlog, which is the maximum queue length for incoming connection requests before the server socket starts to refuse incoming requests.</p>
<p>One of the constructors of the <code>ServerSocket</code> class has the following signature:</p>
<pre><code>public ServerSocket(int port, int backLog, InetAddress bindingAddress);</code></pre>
<p>For this constructor, the binding address must be an instance of <code>java.net.InetAddress</code>. An easy way to construct an <code>InetAddress</code> object is by calling its static method <code>getByName</code>, passing a <code>String</code> containing the host name:</p>
<pre><code>InetAddress.getByName("127.0.0.1");</code></pre>
<p>The following line of code constructs a <code>ServerSocket</code> that listens on port 8080 of the local machine with a backlog of 1.</p>
<pre><code>new ServerSocket(8080, 1, InetAddress.getByName("127.0.0.1"));</code></pre>
<p>Once you have a <code>ServerSocket</code> instance, you can tell it to wait for incoming connection requests by calling the <code>accept</code> method. This method will only return when there is a connection request.  It returns an instance of the <code>Socket</code> class. This <code>Socket</code> object can then be used to send and receive byte streams from the client application, as explained in the <a href="http://www.onjava.com/pub/a/onjava/2003/04/23/java_webserver.html#socket">The Socket Class</a>. Practically, the <code>accept</code> method is the only method used in the application accompanying this article.</p>
<p><!-- sidebar begins --></p>
<table border="0" cellspacing="12" cellpadding="6" width="220" align="right">
<tbody>
<tr>
<td valign="top" bgcolor="#efefef">
<p class="headline">Source Code</p>
<p class="medlist">Download the <a href="http://www.onjava.com/onjava/2003/04/23/examples/HowWebServersWork.zip">HowWebServersWork.zip</a> file for the example application.</p>
</td>
</tr>
</tbody>
</table>
<p><!-- sidebar ends --></p>
<h3>The Application</h3>
<p>Our web server application is part of the <code>ex01.pyrmont</code> package and consists of three classes:</p>
<ul>
<li><code>HttpServer</code></li>
<li><code>Request</code></li>
<li><code>Response</code></li>
</ul>
<p>The entry point of this application (the static <code>main</code> method) is in the <code>HttpServer</code> class. It creates an instance of <code>HttpServer</code> and calls its <code>await</code> method.  As the name implies, <code>await</code> waits for HTTP requests on a designated port, processes them, and sends responses back to the clients. It keeps waiting until a shutdown command is received.  (The method name <code>await</code> is used instead of <code>wait</code> because <code>wait</code> is an important method in the <code>System.Object</code> class for working with threads.)</p>
<p>The application only sends static resources, such as HTML and image files, from a specified directory.  It supports no headers (such as dates or cookies).</p>
<p>We&#8217;ll now take a look at the three classes in the following subsections.</p>
<h4>The <code>HttpServer</code> Class</h4>
<p>The <code>HttpServer</code> class represents a web server and can serve static resources found in the directory indicated by the public static final <code>WEB_ROOT</code> and all subdirectories under it. <code>WEB_ROOT</code> is initialized as follows:</p>
<pre><code>public static final String WEB_ROOT =
	System.getProperty("user.dir") + File.separator  + "webroot";</code></pre>
<p>The code listings include a directory called <em>webroot</em> that contains some static resources that you can use for testing this application. You can also find a servlet that will be used for my next article, &#8220;How Servlet Containers Work.&#8221;</p>
<p>To request a static resource, type the following URL in your browser&#8217;s Address or URL box:</p>
<pre><code>http://machineName:port/staticResource</code></pre>
<p>If you are sending a request from a different machine from the one running your application, <code>machineName</code> is the name or IP address of the computer running this application. If your browser is on the same machine, you can use <code>localhost</code> for the <code>machineName</code>. <code>port</code> is 8080 and <code>staticResource</code> is the name of the file requested and must reside in <code>WEB_ROOT</code>.</p>
<p>For instance, if you are using the same computer to test the application and you want to ask the <code>HttpServer</code> to send the <em>index.html</em> file, use the following URL:</p>
<pre><code>http://localhost:8080/index.html</code></pre>
<p>To stop the server, send a shutdown command from a web browser by typing the pre-defined string in the browser&#8217;s Address or URL box, after the <code>host:port</code> section of the URL. The shutdown command is defined by the <code>SHUTDOWN</code> static final variable in the <code>HttpServer</code> class:</p>
<pre><code>private static final String SHUTDOWN_COMMAND = "/SHUTDOWN";</code></pre>
<p>Therefore, to stop the server, you can use:</p>
<pre><code>http://localhost:8080/SHUTDOWN</code></pre>
<p>Now, let&#8217;s have a look at the <code>await</code> method that is given in Listing 1.1. The explanation of the code is to be found right after the listing.</p>
<p><em>Listing 1.1. The <code>HttpServer</code> class&#8217; <code>await</code> method</em></p>
<pre><code>public void await() {
    ServerSocket serverSocket = null;
    int port = 8080;
    try {
        serverSocket =  new ServerSocket(port, 1,
        InetAddress.getByName("127.0.0.1"));
    }
    catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
    }

    // Loop waiting for a request
    while (!shutdown) {
        Socket socket = null;
        InputStream input = null;
        OutputStream output = null;
        try {
            socket = serverSocket.accept();
            input = socket.getInputStream();
            output = socket.getOutputStream();

            // create Request object and parse
            Request request = new Request(input);
            request.parse();

            // create Response object
            Response response = new Response(output);
            response.setRequest(request);
            response.sendStaticResource();

            // Close the socket
            socket.close();

            //check if the previous URI is a shutdown command
            shutdown = request.getUri().equals(SHUTDOWN_COMMAND);
        }
        catch (Exception e) {
            e.printStackTrace();
            continue;
        }
    }
}</code></pre>
<p>The <code>await</code> method starts by creating a <code>ServerSocket</code> instance and then going into a <code>while</code> loop.</p>
<pre><code>serverSocket =  new ServerSocket(
     port, 1, InetAddress.getByName("127.0.0.1"));

...

// Loop waiting for a request
while (!shutdown) {
    ...
}</code></pre>
<p>The code inside of the <code>while</code> loop stops at the <code>accept</code> method of <code>ServerSocket</code>, which returns only when an HTTP request is received on port 8080:</p>
<pre><code>socket = serverSocket.accept();</code></pre>
<p>Upon receiving a request, the <code>await</code> method obtains the <code>java.io.InputStream</code> and the <code>java.io.OutputStream</code> objects from the <code>Socket</code> instance returned by the <code>accept</code> method.</p>
<pre><code>input = socket.getInputStream();
output = socket.getOutputStream();</code></pre>
<p>The <code>await</code> method then creates a <code>Request</code> object and calls its <code>parse</code> method to parse the raw HTTP request.</p>
<pre><code>// create Request object and parse
Request request = new Request(input);
request.parse();</code></pre>
<p>Next, the <code>await</code> method creates a <code>Response</code> object, sets the <code>Request</code> object to it, and calls its <code>sendStaticResource</code> method.</p>
<pre><code>// create Response object
Response response = new Response(output);
response.setRequest(request);
response.sendStaticResource();</code></pre>
<p>Finally, the <code>await</code> method closes the <code>Socket</code> and calls the <code>getUri</code> method of <code>Request</code> to check if the URI of the HTTP request is a shutdown command. If it is, the shutdown variable is set to <code>true</code> and the program exits the <code>while</code> loop.</p>
<pre><code>// Close the socket
socket.close();
//check if the previous URI is a shutdown command
shutdown = request.getUri().equals(SHUTDOWN_COMMAND);</code></pre>
<p></span></p>
<p></span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xrain.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xrain.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xrain.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xrain.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xrain.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xrain.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xrain.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xrain.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xrain.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xrain.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xrain.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xrain.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xrain.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xrain.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xrain.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xrain.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=11&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xrain.wordpress.com/2008/05/05/how-java-web-servers-work-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c4777157d40cda711fb9d6630c4d8668?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xrain</media:title>
		</media:content>
	</item>
		<item>
		<title>How Java Web Servers Work &#8211; part 1</title>
		<link>http://xrain.wordpress.com/2008/05/05/how-java-web-servers-work-part-1/</link>
		<comments>http://xrain.wordpress.com/2008/05/05/how-java-web-servers-work-part-1/#comments</comments>
		<pubDate>Mon, 05 May 2008 06:42:00 +0000</pubDate>
		<dc:creator>xrain</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[how java webservers work]]></category>

		<guid isPermaLink="false">http://xrain.wordpress.com/?p=10</guid>
		<description><![CDATA[by Budi Kurniawan 04/23/2003Editor&#8217;s Note: this article is adapted from Budi&#8217;s self-published book on Tomcat internals. You can find more information on his web site. A web server is also called a Hypertext Transfer Protocol (HTTP) server because it uses HTTP to communicate with its clients, which are usually web browsers. A Java-based web server [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=10&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span> by <a href="http://www.onjava.com/pub/au/136">Budi Kurniawan</a><br />
04/23/2003<em>Editor&#8217;s Note:  this article is adapted from Budi&#8217;s self-published book on Tomcat internals.  You can find more information on <a href="http://www.brainysoftware.com/">his web site</a>.</em></span></p>
<p><span>A web server is also called a Hypertext Transfer Protocol (HTTP) server because it uses HTTP to communicate with its clients, which are usually web browsers. A Java-based web server uses two important classes, <code>java.net.Socket</code> and <code>java.net.ServerSocket</code>, and communicates through HTTP messages.  Therefore, this article starts by discussing of HTTP and the two classes.  Afterwards, I&#8217;ll explain the simple web server application that accompanies this article.</span></p>
<h3>The Hypertext Transfer Protocol (HTTP)</h3>
<p>HTTP is the protocol that allows web servers and browsers to send and receive data over the Internet. It is a request and response protocol&#8211;the client makes a request and the server responds to the request. HTTP uses reliable TCP connections, by default on TCP port 80. The first version of HTTP was HTTP/0.9, which was then overridden by HTTP/1.0. The current version is HTTP/1.1, which is defined by <a href="http://www.w3.org/Protocols/HTTP/1.1/rfc2616.pdf">RFC 2616</a>(.pdf).</p>
<p>This section covers HTTP 1.1 briefly; enough to make you understand the messages sent by the web server application. If you are interested in more details, read RFC 2616.</p>
<p>In HTTP, the client always initiates a transaction by establishing a connection and sending an HTTP request. The server is in no position to contact a client or to make a callback connection to the client. Either the client or the server can prematurely terminate a connection. For example, when using a web browser, you can click the Stop button on your browser to stop the download process of a file, effectively closing the HTTP connection with the web server.</p>
<h4>HTTP Requests</h4>
<p>An HTTP request consists of three components:</p>
<ul>
<li>Method-URI-Protocol/Version</li>
<li>Request headers</li>
<li>Entity body</li>
</ul>
<p>An example HTTP request is:</p>
<pre><code>POST /servlet/default.jsp HTTP/1.1
Accept: text/plain; text/html
Accept-Language: en-gb
Connection: Keep-Alive
Host: localhost
Referer: http://localhost/ch8/SendDetails.htm
User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)
Content-Length: 33
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate 

LastName=Franks&amp;FirstName=Michael</code></pre>
<p>The method-URI-Protocol/Version appears as the first line of the request.</p>
<pre><code>POST /servlet/default.jsp HTTP/1.1

</code><span>
where <code>POST</code> is the request method,
<code>/servlet/default.jsp</code> represents the URI and <code>HTTP/1.1</code>
the Protocol/Version section.

Each HTTP request can use one of the many request methods, as specified in
the HTTP standards. The HTTP 1.1 supports seven types of request:
<code>GET</code>, <code>POST</code>, <code>HEAD</code>, <code>OPTIONS</code>,
<code>PUT</code>, <code>DELETE</code>, and <code>TRACE</code>. <code>GET</code>
and <code>POST</code> are the most commonly used in Internet applications.

The URI specifies an Internet resource completely. A URI is usually
interpreted as being relative to the server's root directory. Thus, it should
always begin with a forward slash (<code>/</code>). A URL is actually a type of
<a href="http://www.ietf.org/rfc/rfc2396.txt">URI</a>. The protocol version
represents the version of the HTTP protocol being used.

The request header contains useful information about the client environment
and the entity body of the request. For example, it could contain the language
for which the browser is set, the length of the entity body, and so on. Each header
is separated by a carriage return/linefeed (CRLF) sequence.

A very important blank line (CRLF sequence) comes between the headers and
the entity body.  This line marks the beginning of the entity body. Some
Internet programming books consider this CRLF the fourth component of an HTTP
request.

In the previous HTTP request, the entity body is simply the following
line:
<pre><code>LastName=Franks&amp;FirstName=Michael</code></pre>
<p>The entity body could easily become much longer in a typical HTTP<br />
request.</p>
<h4>HTTP Responses</h4>
<p>Similar to requests, an HTTP response also consists of three parts:</p>
<ul>
<li>Protocol-Status code-Description</li>
<li>Response headers</li>
<li>Entity body</li>
</ul>
<p>The following is an example of an HTTP response:</p>
<pre><code>HTTP/1.1 200 OK
Server: Microsoft-IIS/4.0
Date: Mon, 3 Jan 1998 13:13:33 GMT
Content-Type: text/html
Last-Modified: Mon, 11 Jan 1998 13:23:42 GMT
Content-Length: 112

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;HTTP Response Example&lt;/title&gt;&lt;/head&gt;&lt;body&gt;
Welcome to Brainy Software
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<p>The first line of the response header is similar to the first line of the<br />
request header. The first line tells you that the protocol used is HTTP version<br />
1.1, the request succeeded (200 = success), and that everything went okay.</p>
<p>The response headers contain useful information similar to the headers in<br />
the request. The entity body of the response is the HTML content of the<br />
response itself. The headers and the entity body are separated by a sequence of<br />
CRLFs.</p>
<h3><a name="socket">The Socket Class</a></h3>
<p>A socket is an endpoint of a network connection. A socket enables an<br />
application to read from and write to the network. Two software applications<br />
residing on two different computers can communicate with each other by sending<br />
and receiving byte streams over a connection. To send a message to another<br />
application, you need to know its IP address, as well as the port number of its<br />
socket. In Java, a socket is represented by the <code>java.net.Socket</code><br />
class.</p>
<p>To create a socket, you can use one of the many constructors of the<br />
<code>Socket</code> class. One of these constructors accepts the host name and<br />
the port number:</p>
<pre><code>public Socket(String host, int port)</code></pre>
<p>where <code>host</code> is the remote machine name or IP address, and<br />
<code>port</code> is the port number of the remote application. For example, to<br />
connect to yahoo.com at port 80, you would construct the following socket:</p>
<pre><code>new Socket("yahoo.com", 80);</code></pre>
<p>Once you create an instance of the <code>Socket</code> class successfully,<br />
you can use it to send and receive streams of bytes. To send byte streams, you<br />
must first call the <code>Socket</code> class' <code>getOutputStream</code><br />
method to obtain a <code>java.io.OutputStream</code> object. To send text to a<br />
remote application, you often want to construct a<br />
<code>java.io.PrintWriter</code> object from the <code>OutputStream</code><br />
object returned.  To receive byte streams from the other end of the connection,<br />
you call the <code>Socket</code> class' <code>getInputStream</code> method, which<br />
returns a <code>java.io.InputStream</code>.</p>
<p>The following snippet creates a socket that can communicate with a local<br />
HTTP server (127.0.0.1 denotes a local host), sends an HTTP request, and<br />
receives the response from the server. It creates a <code>StringBuffer</code><br />
object to hold the response, and prints it to the console.</p>
<pre><code>Socket socket    = new Socket("127.0.0.1", "8080");
OutputStream os   = socket.getOutputStream();
boolean autoflush = true;
PrintWriter out   = new PrintWriter( socket.getOutputStream(), autoflush );
BufferedReader in = new BufferedReader(
    new InputStreamReader( socket.getInputStream() ));

// send an HTTP request to the web server
out.println("GET /index.jsp HTTP/1.1");
out.println("Host: localhost:8080");
out.println("Connection: Close");
out.println();

// read the response
boolean loop    = true;
StringBuffer sb = new StringBuffer(8096);

while (loop) {
    if ( in.ready() ) {
        int i=0;
        while (i!=-1) {
            i = in.read();
            sb.append((char) i);
        }
        loop = false;
    }
    Thread.currentThread().sleep(50);
}

// display the response to the out console
System.out.println(sb.toString());
socket.close();</code></pre>
<p>Note that to get a proper response from the web server, you need to send an<br />
HTTP request that complies with the HTTP protocol. If you have read the<br />
previous section, "The Hypertext Transfer Protocol (HTTP)," you can<br />
understand the HTTP request in the code above.</p>
<p></span></pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xrain.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xrain.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xrain.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xrain.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xrain.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xrain.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xrain.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xrain.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xrain.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xrain.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xrain.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xrain.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xrain.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xrain.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xrain.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xrain.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=10&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xrain.wordpress.com/2008/05/05/how-java-web-servers-work-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c4777157d40cda711fb9d6630c4d8668?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xrain</media:title>
		</media:content>
	</item>
		<item>
		<title>The difference between Marketing, PR, Advertising and Branding</title>
		<link>http://xrain.wordpress.com/2008/04/26/the-difference-between-marketing-pr-advertising-and-branding/</link>
		<comments>http://xrain.wordpress.com/2008/04/26/the-difference-between-marketing-pr-advertising-and-branding/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 16:51:50 +0000</pubDate>
		<dc:creator>xrain</dc:creator>
				<category><![CDATA[MISC]]></category>

		<guid isPermaLink="false">http://xrain.wordpress.com/?p=8</guid>
		<description><![CDATA[Nguồn: AdOfTheWorld<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=8&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:center;"><img src="http://www.markazine.com/wp-content/uploads/2007/05/1.gif" alt="1.gif" /></p>
<div style="text-align:center;"></div>
<p style="text-align:center;"><img src="http://www.markazine.com/wp-content/uploads/2007/05/2.gif" alt="2.gif" /></p>
<div style="text-align:center;"></div>
<p style="text-align:center;"><img src="http://www.markazine.com/wp-content/uploads/2007/05/3.gif" alt="3.gif" /></p>
<div style="text-align:center;"></div>
<p style="text-align:center;"><img src="http://www.markazine.com/wp-content/uploads/2007/05/4.gif" alt="4.gif" /></p>
<p style="text-align:left;">Nguồn: <a href="http://adsoftheworld.com/blog/ivan/2007/apr/11/the_difference_between_marketing_pr_advertising_and_branding">AdOfTheWorld</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xrain.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xrain.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xrain.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xrain.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xrain.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xrain.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xrain.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xrain.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xrain.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xrain.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xrain.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xrain.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xrain.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xrain.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xrain.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xrain.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=8&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xrain.wordpress.com/2008/04/26/the-difference-between-marketing-pr-advertising-and-branding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c4777157d40cda711fb9d6630c4d8668?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xrain</media:title>
		</media:content>

		<media:content url="http://www.markazine.com/wp-content/uploads/2007/05/1.gif" medium="image">
			<media:title type="html">1.gif</media:title>
		</media:content>

		<media:content url="http://www.markazine.com/wp-content/uploads/2007/05/2.gif" medium="image">
			<media:title type="html">2.gif</media:title>
		</media:content>

		<media:content url="http://www.markazine.com/wp-content/uploads/2007/05/3.gif" medium="image">
			<media:title type="html">3.gif</media:title>
		</media:content>

		<media:content url="http://www.markazine.com/wp-content/uploads/2007/05/4.gif" medium="image">
			<media:title type="html">4.gif</media:title>
		</media:content>
	</item>
		<item>
		<title>Ngôn ngữ lập trình Python</title>
		<link>http://xrain.wordpress.com/2008/04/25/ngon-ng%e1%bb%af-l%e1%ba%adp-trinh-python/</link>
		<comments>http://xrain.wordpress.com/2008/04/25/ngon-ng%e1%bb%af-l%e1%ba%adp-trinh-python/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 13:15:50 +0000</pubDate>
		<dc:creator>xrain</dc:creator>
				<category><![CDATA[MISC]]></category>

		<guid isPermaLink="false">http://xrain.wordpress.com/?p=5</guid>
		<description><![CDATA[Python là một ngôn ngữ lập trình thông dịch do Guido van Rossum tạo ra năm 1990. Python hoàn toàn tạo kiểu động và dùng cơ chế cấp phát bộ nhớ tự động; do vậy nó gần giống như Perl, Ruby, Scheme, Smalltalk, và Tcl. Python được phát triển trong một dự án mã mở, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=5&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a title="E-mail" href="http://vimes.com.vn/index2.php?option=com_content&amp;task=emailform&amp;id=3168&amp;itemid=99999999" target="_blank"> <img src="http://vimes.com.vn/templates/ja_antares/images/emailButton.png" border="0" alt="E-mail" align="middle" /></a></p>
<p><img src="http://vimes.com.vn/images/stories/CLBIT/python_logo.png" border="0" alt="Image" hspace="6" width="150" height="50" /></p>
<p>Python là một ngôn ngữ lập trình thông dịch do Guido van Rossum tạo ra năm 1990. Python hoàn toàn tạo kiểu động và dùng cơ chế cấp phát bộ nhớ tự động; do vậy nó gần giống như Perl, Ruby, Scheme, Smalltalk, và Tcl. Python được phát triển trong một dự án mã mở, do tổ chức phi lợi nhuận Python Software Foundation quản lý. Bản mới nhất hiện nay là Python 2.5 được phát hành vào 19 tháng 9, 2006.<br />
Theo đánh giá của Eric S. Raymond, Python là ngôn ngữ có hình thức rất sáng sủa, cấu trúc rõ ràng, thuận tiện cho người mới học lập trình. Cấu trúc của Python còn cho phép người sử dụng viết mã lệnh với số lần gõ phím tối thiểu, như nhận định của chính Guido van Rossum trong một bài phỏng vấn ông.</p>
<p>Ban đầu, Python được phát triển để chạy trên nền Unix. Nhưng rồi theo thời gian, nó đã “bành trướng” sang mọi hệ điều hành từ DOS đến Mac OS, OS/2, Windows, Linux và các hệ điều hành khác thuộc họ Unix. Mặc dù sự phát triển của Python có sự đóng góp của rất nhiều cá nhân, nhưng Guido van Rossum hiện nay vẫn là tác giả chủ yếu của Python. Ông giữ vai trò chủ chốt trong việc quyết định hướng phát triển của Python.</p>
<h2><span class="mw-headline">Lịch sử</span></h2>
<p>Sự phát triển Python đến nay có thể chia làm các giai đoạn:</p>
<p>* Python 1: bao gồm các bản phát hành 1.x. Giai đoạn này, kéo dài từ đầu đến cuối thập niên 1990. Từ năm 1990 đến 1995, Guido làm việc tại CWI (Centrum voor Wiskunde en Informatica &#8211; Trung tâm Toán-Tin học) tại Amsterdam, Hà Lan). Vì nguyên nhân này, các phiên bản Python đầu tiên đều do CWI phát hành. Phiên bản cuối cùng phát hành tại CWI là 1.2.<br />
o Vào năm 1995, Guido chuyển sang Corporation for National Research Initiatives (CNRI) ở Reston, Virginia. Tại đây, ông phát hành một số phiên bản khác. Python 1.6 là phiên bản cuối cùng phát hành tại CNRI.<br />
o Sau bản phát hành 1.6, Guido rời bỏ CNRI để làm việc với các lập trình viên chuyên viết phần mềm thương mại. Tại đây, ông có ý tưởng sử dụng Python với các phần mềm tuân theo chuẩn GPL. Sau đó, CNRI và Free Software Foundation (FSF) đã cùng nhau hợp tác để làm bản quyền Python phù hợp với GPL. Cùng năm đó, Guido được nhận giải thưởng FSF Award for the Advancement of Free Software.<br />
o Phiên bản 1.6.1 ra đời sau đó là phiên bản đâu tiền tuân theo bản quyền GPL. Tuy nhiên, bản này hoàn toàn giống bản 1.6, trừ một số sửa lỗi cần thiết.</p>
<p>* Python 2: vào năm 2000, Guido và nhóm phát triển Python dời đến BeOpen.com và thành lập BeOpen PythonLabs team. Phiên bản Python 2.0 được phát hành tại đây. Sau khi phát hành Python 2.0, Guido và các thành viên PythonLabs gia nhập Digital Creations.</p>
<p>o Python 2.1 ra đời kế thừa từ Python 1.6.1 và Python 2.0. Bản quyền của phiên bản này được đổi thành Python Software Foundation License. Từ thời điểm này trở đi, Python thuộc sở hữu của Python Software Foundation (PSF), một tổ chức phi lợi nhuận được thành lập theo mẫu Apache Software Foundation.<br />
* Python 3: Về sự phát triển của Python trong tương lai, các nhà phát triển vẫn đang thảo luận về phiên bản mới: Python 3.0 (dự án gọi là Python 3000 hoặc Py3K). Dự kiến, dòng 3.x sẽ không hoàn toàn tương thích với dòng 2.x. Nhóm phát triển cho biết sẽ lấp những chỗ hở của ngôn ngữ. Nguyên tắc chủ đạo để phát triển Python 3.x là &#8220;bỏ cách làm việc cũ nhằm hạn chế trùng lặp về mặt chức năng của Python&#8221;. Tuy nhiên, cho đến nay, vẫn chưa có kế hoạch cụ thể để phát triển Python 3.0, dù vậy, PEP (Python Enhancement Proposal) trong đó mô tả chi tiết các thay đổi trong Python đã có tại http://www.python.org/peps/pep-3000.html.</p>
<p><a name=".C4.90.E1.BA.B7c_.C4.91i.E1.BB.83m"></a></p>
<h2><span class="mw-headline"><br />
</span></h2>
<h2><span class="mw-headline">Đặc điểm</span></h2>
<p><a name="D.E1.BB.85_h.E1.BB.8Dc.2C_d.E1.BB.85_.C4.91.E1.BB.8Dc"></a></p>
<h3><span class="mw-headline">Dễ học, dễ đọc</span></h3>
<p>Python được thiết kế để trở thành một ngôn ngữ dễ học, mã nguồn dễ đọc, bố cục trực quan, dễ hiểu, thể hiện qua các điểm sau:</p>
<p><a name="T.E1.BB.AB_kh.C3.B3a"></a></p>
<h4><span class="mw-headline">Từ khóa</span></h4>
<p>Python tăng cường sử dụng từ khóa tiếng Anh, hạn chế các kí hiệu và cấu trúc cú pháp so với các ngôn ngữ khác. Python là một ngôn ngữ phân biệt kiểu chữ. Như C/C++, các từ khóa của Python đều ở dạng chữ thường.</p>
<p><a name="Kh.E1.BB.91i_l.E1.BB.87nh"></a></p>
<h4><span class="mw-headline">Khối lệnh</span></h4>
<p>Trong các ngôn ngữ khác, khối lệnh thường được đánh dấu bằng cặp kí hiệu hoặc từ khóa. Ví dụ, trong C/C++, cặp { } được dùng để bao bọc một khối lệnh. Python, trái lại, có một cách rất đặc biệt để tạo khối lệnh, đó là thụt các câu lệnh trong khối vào sâu hơn (về bên phải) so với các câu lệnh của khối lệnh cha chứa nó. Ví dụ, giả sử có đoạn mã sau trong C/C++:</p>
<pre>#include &lt;math.h&gt;
//...
delta = b * b – 4 * a * c;
if (delta &gt; 0)
{
   // Khối lệnh mới bắt đầu từ kí tự { đến }
   x1 = (- b + sqrt(delta)) / (2 * a);
   x2 = (- b - sqrt(delta)) / (2 * a);
   printf("Phuong trinh co hai nghiem phan biet:\n");
   printf("x1 = %f; x2 = %f", x1, x2);
}
</pre>
<p>Đoạn mã trên có thể được viết lại bằng Python như sau:</p>
<pre>import math
#...
delta = b * b – 4 * a * c
if delta &gt; 0:
    # Khối lệnh mới, thụt vào đầu dòng
    x1 = (- b + math.sqrt(delta)) / (2 * a)
    x2 = (- b – math.sqrt(delta)) / (2 * a)
    print "Phuong trinh co hai nghiem phan biet:"
    print "x1 = ", x1, "; ", "x2 = ", x2
</pre>
<p>Ta có thể sử dụng tab hoặc khoảng trống để thụt các câu lệnh vào.</p>
<p><a name="C.C3.A1c_b.E1.BA.A3n_hi.E1.BB.87n_th.E1.BB.B1c"></a></p>
<h3><span class="mw-headline">Các bản hiện thực</span></h3>
<p>Python được viết từ những ngôn ngữ khác, tạo ra những bản hiện thực khác nhau. Bản hiện thực Python chính, còn gọi là CPython, được viết bằng C, và được phân phối kèm một thư viện chuẩn lớn được viết hỗn hợp bằng C và Python. CPython có thể chạy trên nhiều nền và khả chuyển trên nhiều nền khác. Dưới đây là các nền trên đó, CPython có thể chạy.</p>
<ul>
<li>Các hệ điều hành họ <a title="Unix" href="http://vi.wikipedia.org/wiki/Unix">Unix</a>: <a title="AIX" href="http://vi.wikipedia.org/w/index.php?title=AIX&amp;action=edit">AIX</a>, BSD, Darwin, <a title="FreeBSD" href="http://vi.wikipedia.org/wiki/FreeBSD">FreeBSD</a>, <a title="Mac OS X" href="http://vi.wikipedia.org/wiki/Mac_OS_X">Mac OS X</a>, NetBSD, <a title="Linux" href="http://vi.wikipedia.org/wiki/Linux">Linux</a>, OpenBSD, <a title="Solaris" href="http://vi.wikipedia.org/w/index.php?title=Solaris&amp;action=edit">Solaris</a>,…</li>
<li>Các hệ điều hành dành cho máy desktop: Amiga, AROS, BeOS, <a title="Mac OS 9" href="http://vi.wikipedia.org/w/index.php?title=Mac_OS_9&amp;action=edit">Mac OS 9</a>, <a title="Microsoft Windows" href="http://vi.wikipedia.org/wiki/Microsoft_Windows">Microsoft Windows</a>, OS/2, RISC OS.</li>
<li>Các hệ thống nhúng và các hệ đặc biệt: GP2X, <a title="Java virtual machine" href="http://vi.wikipedia.org/w/index.php?title=Java_virtual_machine&amp;action=edit">Java virtual machine</a>, Nokia 770 Internet Tablet, <a title="Palm OS" href="http://vi.wikipedia.org/w/index.php?title=Palm_OS&amp;action=edit">Palm OS</a>, PlayStation 2, PlayStation Portable, Psion, QNX, Sharp Zaurus, <a title="Symbian OS" href="http://vi.wikipedia.org/w/index.php?title=Symbian_OS&amp;action=edit">Symbian OS</a>, <a title="Windows CE" href="http://vi.wikipedia.org/w/index.php?title=Windows_CE&amp;action=edit">Windows CE</a>/<a title="Pocket PC" href="http://vi.wikipedia.org/wiki/Pocket_PC">Pocket PC</a>, Xbox/XBMC, VxWorks.</li>
<li>Các hệ máy tính lớn và các hệ khác: AS/400, OS/390, Plan 9 from <a title="Bell Labs" href="http://vi.wikipedia.org/w/index.php?title=Bell_Labs&amp;action=edit">Bell Labs</a>, <a title="VMS" href="http://vi.wikipedia.org/w/index.php?title=VMS&amp;action=edit">VMS</a>, z/OS.</li>
</ul>
<p>Ngoài CPython, còn có hai hiện thực Python khác: <a title="Jython" href="http://vi.wikipedia.org/w/index.php?title=Jython&amp;action=edit">Jython</a> cho môi trường <a title="Java" href="http://vi.wikipedia.org/wiki/Java">Java</a> và <a title="IronPython" href="http://vi.wikipedia.org/w/index.php?title=IronPython&amp;action=edit">IronPython</a> cho môi trường <a title=".NET" href="http://vi.wikipedia.org/w/index.php?title=.NET&amp;action=edit">.NET</a> và Mono.</p>
<p><a name="Kh.E1.BA.A3_n.C4.83ng_m.E1.BB.9F_r.E1.BB.99ng"></a></p>
<h3><span class="mw-headline">Khả năng mở rộng</span></h3>
<p>Python có thể được mở rộng: nếu ta biết sử dụng C, ta có thể dễ dàng viết và tích hợp vào Python nhiều hàm tùy theo nhu cầu. Các hàm này sẽ trở thành hàm xây dựng sẵn (built-in) của Python. Ta cũng có thể mở rộng chức năng của trình thông dịch, hoặc liên kết các chương trình Python với các thư viện chỉ ở dạng nhị phân (như các thư viện đồ họa do nhà sản xuất thiết bị cung cấp). Hơn thế nữa, ta cũng có thể liên kết trình thông dịch của Python với các ứng dụng viết từ C và sử dụng nó như là một mở rộng hoặc một ngôn ngữ dòng lệnh phụ trợ cho ứng dụng đó.</p>
<p><a name="Tr.C3.ACnh_th.C3.B4ng_d.E1.BB.8Bch"></a></p>
<h3><span class="mw-headline">Trình thông dịch</span></h3>
<p>Python là một ngôn ngữ lập trình dạng thông dịch. Ưu điểm của thông dịch là giúp ta tiết kiệm thời gian phát triển ứng dụng vì không cần phải thực hiện biên dịch và liên kết. Trình thông dịch có thể được sử dụng để chạy file script, hoặc cũng có thể được sử dụng một cách tương tác. Ở chế độ tương tác, trình thông dịch Python tương tự shell của các hệ điều hành họ Unix, tại đó, ta có thể nhập vào một biểu thức tại một thời điểm rồi enter, và kết quả thực thi sẽ được hiển thị ngay lập tức. Đặc điểm này rất hữu ích cho người mới học, giúp họ nghiên cứu tính năng của ngôn ngữ; hoặc để các lập trình viên chạy thử mã trong suốt quá trình phát triển phần mềm. Ngoài ra, nó cũng có thể được sử dụng như là một máy tính.</p>
<p><a name="L.E1.BB.87nh_v.C3.A0_c.E1.BA.A5u_tr.C3.BAc_.C4.91i.E1.BB.81u_khi.E1.BB.83n"></a></p>
<h3><span class="mw-headline">Lệnh và cấu trúc điều khiển</span></h3>
<p>Mỗi câu lệnh trong Python nằm trên một dòng mã nguồn. Ta không cần phải kết thúc câu lệnh bằng bất kì kí tự gì. Cũng như các ngôn ngữ khác, Python cũng có các cấu trúc điều khiển. Chúng bao gồm:</p>
<ul>
<li>Cấu trúc rẽ nhánh: cấu trúc if (có thể sử dụng thêm elif hoặc else), dùng để thực thi có điều kiện một khối mã cụ thể.</li>
<li>Cấu trúc lặp, bao gồm:</li>
</ul>
<ul>
<li>Lệnh while: chạy một khối mã cụ thể cho đến khi điều kiện lặp có giá trị false.</li>
<li>Vòng lặp for: lặp qua từng phần tử của một dãy, mỗi phần tử sẽ được đưa vào biến cục bộ để sử dụng với khối mã trong vòng lặp.</li>
</ul>
<ul>
<li>Python cũng có từ khóa class dùng để khai báo lớp (sử dụng trong lập trình hướng đối tượng) và lệnh def dùng để định nghĩa hàm.</li>
</ul>
<p><a name="H.E1.BB.87_th.E1.BB.91ng_ki.E1.BB.83u_d.E1.BB.AF_li.E1.BB.87u"></a></p>
<h3><span class="mw-headline">Hệ thống kiểu dữ liệu</span></h3>
<p>Python sử dụng hệ thống kiểu <em>duck typing</em>, còn gọi là <em>latent typing</em> (hàm nghĩa: ngầm). Có nghĩa là, Python không kiểm tra các ràng buộc về kiểu dữ liệu tại thời điểm dịch, mà là tại thời điểm thực thi. Khi thực thi, nếu một thao tác trên một đối tượng bị thất bại, thì có nghĩa là, đối tượng đó không sử dụng một kiểu thích hợp. Python cũng là một ngôn ngữ định kiểu mạnh. Nó cấm mọi thao tác không hợp lệ, ví dụ cộng một con số vào chuỗi. Sử dụng Python, ta không cần phải khai báo biến. Biến được xem là đã khai báo nếu nó được gán một giá trị lần đầu tiên. Căn cứ vào mỗi lần gán, Python sẽ tự động xác định kiểu dữ liệu của biến. Python có một số kiểu dữ liệu thông dụng sau:</p>
<ul>
<li>int, long: số nguyên</li>
<li>float: số thực</li>
<li>complex: số phức</li>
<li>list: chuỗi có thể thay đổi</li>
<li>tuple: chuỗi không thể thay đổi</li>
<li>str: chuỗi kí tự không thể thay đổi</li>
<li>dict: từ điển</li>
<li>set: một tập không xếp theo thứ tự, ở đó, mỗi phần tử chỉ xuất hiện một lần.</li>
</ul>
<p>Ngoài ra, Python còn có nhiều kiểu dữ liệu khác.</p>
<p><a name="Module"></a></p>
<h3><span class="mw-headline">Module</span></h3>
<p>Python cho phép chia chương trình thành modules để có thể sử dụng lại trong các chương trình khác. Nó cũng có sẵn một tập hợp các modules chuẩn mà ta có thể sử dụng lại trong chương trình của ta. Các thư viện này cung cấp nhiều thứ, như file I/O, các lời gọi hệ thống, sockets,…</p>
<p><a name=".C4.90a_n.C4.83ng"></a></p>
<h3><span class="mw-headline">Đa năng</span></h3>
<p>Python là một ngôn ngữ lập trình đơn giản nhưng rất hiệu quả. So với Unix shell, Python hỗ trợ các chương trình lớn hơn và cung cấp nhiều cấu trúc hơn. So với C, Python cung cấp nhiều cơ chế kiểm tra lỗi hơn. Vì các lí do đó, Python là một ngôn ngữ lập trình cấp rất cao. Nó cũng có sẵn nhiều kiểu dữ liệu cấp cao, ví dụ như các mảng linh hoạt (flexible arrays) ( ) và từ điển (dictionaries) mà ta phải mất nhiều thời gian để hiện thực trên C. Python cũng thích hợp với các chương trình lớn hơn cả <a title="Awk" href="http://vi.wikipedia.org/w/index.php?title=Awk&amp;action=edit">Awk</a> và Perl. Python cũng được sử dụng để lập trình Web. Nó có thể được sử dụng như là một <a title="Ngôn ngữ kịch bản" href="http://vi.wikipedia.org/w/index.php?title=Ng%C3%B4n_ng%E1%BB%AF_k%E1%BB%8Bch_b%E1%BA%A3n&amp;action=edit">ngôn ngữ kịch bản</a>. Python được thiết kế để có thể nhúng và phục vụ như là một ngôn ngữ kịch bản để tuỳ biến và mở rộng các ứng dụng lớn hơn. Được tích hợp sẵn nhiều công cụ và có một thư viện chuẩn phong phú, Python cho phép người dùng dễ dàng tạo ra các <a title="Dịch vụ Web" href="http://vi.wikipedia.org/wiki/D%E1%BB%8Bch_v%E1%BB%A5_Web">dịch vụ Web</a>, sử dụng các thành phần <a title="COM" href="http://vi.wikipedia.org/w/index.php?title=COM&amp;action=edit">COM</a> hay <a title="CORBA" href="http://vi.wikipedia.org/w/index.php?title=CORBA&amp;action=edit">CORBA</a> ( ). Nó hỗ trợ các <a title="Định dạng" href="http://vi.wikipedia.org/w/index.php?title=%C4%90%E1%BB%8Bnh_d%E1%BA%A1ng&amp;action=edit">định dạng</a> <a title="Email" href="http://vi.wikipedia.org/wiki/Email">email</a>, dữ liệu Internet, <a title="HTML" href="http://vi.wikipedia.org/wiki/HTML">HTML</a>, <a title="XML" href="http://vi.wikipedia.org/wiki/XML">XML</a> và các <a title="Ngôn ngữ đánh dấu" href="http://vi.wikipedia.org/wiki/Ng%C3%B4n_ng%E1%BB%AF_%C4%91%C3%A1nh_d%E1%BA%A5u">ngôn ngữ đánh dấu</a> khác. Python cũng ứng dụng tất cả các giao thức <a title="Internet" href="http://vi.wikipedia.org/wiki/Internet">Internet</a> thông dụng như <a title="HTTP" href="http://vi.wikipedia.org/w/index.php?title=HTTP&amp;action=edit">HTTP</a>, <a title="FTP" href="http://vi.wikipedia.org/wiki/FTP">FTP</a>,… Python cung cấp giao tiếp đến hầu hết cơ sở dữ liệu, có khả năng xử lí văn bản, tài liệu hiệu quả, và có thể làm việc tốt với các công nghệ Web khác. Python cũng đặc biệt hiệu quả cho lập trình tính toán khoa học qua các công cụ <a title="Python Imaging Library" href="http://vi.wikipedia.org/w/index.php?title=Python_Imaging_Library&amp;action=edit">Python Imaging Library</a>, <a title="VTK" href="http://vi.wikipedia.org/w/index.php?title=VTK&amp;action=edit">VTK</a>, MayaVi 3D Visualization Toolkits, <a title="Numeric Python" href="http://vi.wikipedia.org/w/index.php?title=Numeric_Python&amp;action=edit">Numeric Python</a>, <a title="ScientificPython" href="http://vi.wikipedia.org/w/index.php?title=ScientificPython&amp;action=edit">ScientificPython</a>,… Python cũng có thể được sử dụng để phát triển các ứng dụng Desktop. Người dùng có thể dùng <a title="WxPython" href="http://vi.wikipedia.org/w/index.php?title=WxPython&amp;action=edit">wxPython</a>, <a title="PyQt" href="http://vi.wikipedia.org/w/index.php?title=PyQt&amp;action=edit">PyQt</a>, <a title="PyGtk" href="http://vi.wikipedia.org/w/index.php?title=PyGtk&amp;action=edit">PyGtk</a> để phát triển các ứng dụng giao diện đồ họa (<a title="GUI" href="http://vi.wikipedia.org/wiki/GUI">GUI</a>) chất lượng cao. Python có thể hỗ trợ các GUI frameworks khác như <a title="MFC" href="http://vi.wikipedia.org/w/index.php?title=MFC&amp;action=edit">MFC</a>, <a title="Carbon" href="http://vi.wikipedia.org/wiki/Carbon">Carbon</a>, <a title="Delphi" href="http://vi.wikipedia.org/wiki/Delphi">Delphi</a>, <a title="X11" href="http://vi.wikipedia.org/w/index.php?title=X11&amp;action=edit">X11</a>, <a title="Motif" href="http://vi.wikipedia.org/w/index.php?title=Motif&amp;action=edit">Motif</a>, và <a title="Tk" href="http://vi.wikipedia.org/wiki/Tk">Tk</a>. Python cũng có sẵn một unit testing framework để tạo ra các các bộ test (test suites).</p>
<p><a name="Multiple_paradigms_.28.C4.91a_bi.E1.BA.BFn_h.C3.B3a.29"></a></p>
<h3><span class="mw-headline">Multiple paradigms (đa biến hóa)</span></h3>
<p>Python là một ngôn ngữ đa biến hóa (multiple paradigms). Có nghĩa là, thay vì ép buộc mọi người phải sử dụng duy nhất một phương pháp lập trình, Python lại cho phép sử dụng nhiều phương pháp lập trình khác nhau: hướng đối tượng, có cấu trúc, chức năng, hoặc chỉ hướng đến một khía cạnh. Python kiểu kiểu động và sử dụng bộ thu gom rác để quản lí bộ nhớ. Một đặc điểm quan trọng nữa của Python là giải pháp tên động, kết nối tên biến và tên phương thức lại với nhau trong suốt thực thi của chương trình.</p>
<p><a name="S.E1.BB.B1_t.C6.B0.C6.A1ng_.C4.91.C6.B0.C6.A1ng_gi.E1.BB.AFa_true_v.C3.A0_m.E1.BB.99t_gi.C3.A1_tr.E1.BB.8B_kh.C3.A1c_0"></a></p>
<h3><span class="mw-headline">Sự tương đương giữa true và một giá trị khác 0</span></h3>
<p>Cũng như C/C++, bất kì một giá trị khác 0 nào cũng tương đương với true và ngược lại, một giá trị 0 tương đương với false. Như vậy:</p>
<pre>if a != 0:
</pre>
<p>tương đương với</p>
<pre>if a:
</pre>
<p><a name="C.C3.BA_ph.C3.A1p"></a></p>
<h2><span class="mw-headline">Cú pháp</span></h2>
<p>Sau đây là cú pháp cơ bản nhất của ngôn ngữ Python</p>
<p><a name="To.C3.A1n_t.E1.BB.AD"></a></p>
<h3><span class="mw-headline">Toán tử</span></h3>
<pre>+  -  *  /   // (chia làm tròn)   % (phần dư)   ** (lũy thừa)
~ (not)   &amp; (and)   | (or)   ^ (xor)
&lt;&lt; (left shift)   &gt;&gt; (right shift)
== (bằng)   &lt;=   &gt;=   != (khác)
</pre>
<p>Python sử dụng <a title="K pháp trung tố" href="http://vi.wikipedia.org/w/index.php?title=K%C3%AD_ph%C3%A1p_trung_t%E1%BB%91&amp;action=edit">kí pháp trung tố</a> thường gặp trong các ngôn ngữ lập trình khác.</p>
<p><a name="C.C3.A1c_ki.E1.BB.83u_d.E1.BB.AF_li.E1.BB.87u"></a></p>
<h3><span class="mw-headline">Các kiểu dữ liệu</span></h3>
<ul>
<li>Kiểu số</li>
</ul>
<pre>1234585396326 (số nguyên dài vô hạn)  -86.12   7.84E-04
2j     3 + 8j (số phức)
</pre>
<ul>
<li>Kiểu chuỗi (string)</li>
</ul>
<pre>"Hello"    "It's me"     '"OK"-he replied'
</pre>
<ul>
<li>Kiểu tuple</li>
</ul>
<pre>(1, 2.0, 3)   (1,)    ("Hello",1,())
</pre>
<ul>
<li>Kiểu list</li>
</ul>
<pre>[4.8, -6]    ['a','b']
</pre>
<ul>
<li>Kiểu dictionary</li>
</ul>
<pre>{"Vietnam":"Hanoi", "Netherlands":"Amsterdam", "France":"Paris"}
</pre>
<p><a name="Ch.C3.BA_th.C3.ADch"></a></p>
<h3><span class="mw-headline">Chú thích</span></h3>
<pre># dòng chú thích
</pre>
<p><a name="L.E1.BB.87nh_g.C3.A1n"></a></p>
<h3><span class="mw-headline">Lệnh gán</span></h3>
<pre>tên biến = biểu thức
x = 23.8
y = -x ** 2
z1 = z2 = x + y
loiChao = "Hello!"
</pre>
<pre>i += 1    # tăng biến i thêm 1 đơn vị
</pre>
<p><a name="In_gi.C3.A1_tr.E1.BB.8B"></a></p>
<h3><span class="mw-headline">In giá trị</span></h3>
<pre>print biểu thức
print (7 + 8) / 2.0
print (2 + 3j) * (4 - 6j)
</pre>
<p>Nội suy chuỗi (string interpolation)</p>
<pre>print "Hello %s" %("world!")
print "i = %d" %i
print "a = %.2f and b = %.3f" %(a,b)
</pre>
<p><a name="C.E1.BA.A5u_tr.C3.BAc_r.E1.BA.BD_nh.C3.A1nh"></a></p>
<h3><span class="mw-headline">Cấu trúc rẽ nhánh</span></h3>
<ul>
<li>Dạng 1:</li>
</ul>
<pre>if biểu_thức_đúng:
   # lệnh ...
</pre>
<ul>
<li>Dạng 2:</li>
</ul>
<pre>if biểu_thức_đúng:
   # lệnh ...
else:
   # lệnh ...
</pre>
<ul>
<li>Dạng 3:</li>
</ul>
<pre>if biểu_thức_đúng:
   # lệnh ...
elif:
   # lệnh ...
else:
   # lệnh ...
</pre>
<p><a name="C.E1.BA.A5u_tr.C3.BAc_l.E1.BA.B7p"></a></p>
<h3><span class="mw-headline">Cấu trúc lặp</span></h3>
<pre>while biểu_thức_đúng:
   # lệnh ...
</pre>
<pre>for phần_tử in dãy:
   # lệnh ...
</pre>
<pre>L = ["Ha Noi", "Hai Phong", "TP Ho Chi Minh"]
for thanhPho in L:
   print thanhPho
</pre>
<pre>for i in range(10):
   print i
</pre>
<p><a name="H.C3.A0m"></a></p>
<h3><span class="mw-headline">Hàm</span></h3>
<pre>def tên_hàm (tham_biến_1, tham_biến_2, ...)
   # lệnh ...
   return giá_trị_hàm
</pre>
<pre>def binhPhuong(x):
   return x*x
</pre>
<p>Hàm với tham số mặc định:</p>
<pre>def luyThua(x, n=2):
  """Lũy thừa với số mũ mặc định là 2"""
  return x**n
</pre>
<pre>print luyThua(3)   # 9
print luyThua(2,3) # 8
</pre>
<p><a name="L.E1.BB.9Bp"></a></p>
<h3><span class="mw-headline">Lớp</span></h3>
<pre>class <em>Tên_Lớp_1</em>:
  # ...
</pre>
<pre>class <em>Tên_Lớp_2</em>(<em>Tên_Lớp_1</em>):
  """Lớp 2 kế thừa lớp 1"""
  x = 3  # biến thành viên của lớp
  #
  def <em>phương_thức</em>(self,<em>tham_biến</em>):
    # ...
</pre>
<pre># khởi tạo
a = <em>Tên_Lớp_2</em>()
print a.x
print a.<em>phương_thức</em>(m)  # m là giá trị gán cho tham biến
</pre>
<p><a name="X.E1.BB.AD_l.C3.AD_l.E1.BB.97i"></a></p>
<h3><span class="mw-headline">Xử lí lỗi</span></h3>
<pre>try:
  <em>câu_lệnh</em>
except <em>Loại_Lỗi</em>:
  <em>thông báo lỗi</em></pre>
<p>Theo wikipedia</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xrain.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xrain.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xrain.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xrain.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xrain.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xrain.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xrain.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xrain.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xrain.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xrain.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xrain.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xrain.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xrain.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xrain.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xrain.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xrain.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=5&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xrain.wordpress.com/2008/04/25/ngon-ng%e1%bb%af-l%e1%ba%adp-trinh-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c4777157d40cda711fb9d6630c4d8668?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xrain</media:title>
		</media:content>

		<media:content url="http://vimes.com.vn/templates/ja_antares/images/emailButton.png" medium="image">
			<media:title type="html">E-mail</media:title>
		</media:content>

		<media:content url="http://vimes.com.vn/images/stories/CLBIT/python_logo.png" medium="image">
			<media:title type="html">Image</media:title>
		</media:content>
	</item>
		<item>
		<title>Tìm hiểu về BREW trên điện thoại di động CDMA</title>
		<link>http://xrain.wordpress.com/2008/04/25/tim-hi%e1%bb%83u-v%e1%bb%81-brew-tren-di%e1%bb%87n-tho%e1%ba%a1i-di-d%e1%bb%99ng-cdma/</link>
		<comments>http://xrain.wordpress.com/2008/04/25/tim-hi%e1%bb%83u-v%e1%bb%81-brew-tren-di%e1%bb%87n-tho%e1%ba%a1i-di-d%e1%bb%99ng-cdma/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 09:24:55 +0000</pubDate>
		<dc:creator>xrain</dc:creator>
				<category><![CDATA[BREW]]></category>

		<guid isPermaLink="false">http://xrain.wordpress.com/?p=4</guid>
		<description><![CDATA[BREW (Binary Runtime Environment for Wireless) là một giải pháp về dữ liệu của Qualcomm trong lĩnh vực không dây. Tuy ra đời chưa lâu, nhưng BREW đã có những bước phát triển đáng kể, ngày càng trở nên phổ biến trên thế giới. Hiện nay đã có hơn 60 nhà cung cấp các ứng [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=4&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a title="E-mail" href="http://vimes.com.vn/index2.php?option=com_content&amp;task=emailform&amp;id=3147&amp;itemid=69" target="_blank"> </a></p>
<p><strong><img src="http://vimes.com.vn/images/stories/CLBIT/brew_logo.gif" border="0" alt="Image" hspace="6" width="89" height="58" />BREW (Binary Runtime Environment for Wireless)</strong> là một giải pháp về dữ liệu của Qualcomm trong lĩnh vực không dây. Tuy ra đời chưa lâu, nhưng BREW đã có những bước phát triển đáng kể, ngày càng trở nên phổ biến trên thế giới.</p>
<p>Hiện nay đã có hơn 60 nhà cung cấp các ứng dụng BREW ở hàng chục nước trên thế giới, cùng rất nhiều nhà phát triển ở khắp năm châu. Với sự phát triển không ngừng trong lĩnh vực không dây, khi tốc độ truyền số liệu ngày càng được cải thiện (với công nghệ EV-DO sắp được triển khai của mạng 092, tốc độ tối đa lên tới 2Mb/s), các ứng dụng BREW sẽ phát triển hơn nữa trong tương lai. Vậy BREW có ưu điểm gì?</p>
<p>Như đã nói ở trên, BREW là một giải pháp, trong đó gồm có hai công nghệ:</p>
<p><strong>Công nghệ phần mềm:</strong> Để các nhà phát triển xây dựng các ứng dụng của mình.<br />
<strong>Công nghệ phân phối:</strong> Để nhà cung cấp dịch vụ đưa ứng dụng vào thị trường.</p>
<p>Trước hết hãy nói tới công nghệ phần mềm.Trước đây, các nhà phát triển khi xây dựng các ứng dụng cho điện thoại di động thường mong muốn có một công cụ dễ sử dụng, kiểm soát lỗi tốt, ứng dụng được phát triển có kích thước nhỏ, chạy nhanh, tốn ít bộ nhớ, BREW hoàn toàn đáp ứng được các mong mỏi đó.</p>
<p><strong>- Nhanh:</strong> BREW nằm kề ngay lõi của cấu trúc chipset, sát trên phần mềm hệ thống chíp, để tăng cường các tính năng như dịch vụ định vị, MMS và BREWChat, cũng như tích hợp dễ dàng các bộ trình duyệt và máy ảo (virtual machiné) cho phép mở rộng và thực thi nhanh chóng các ứng dụng viết bằng C/C++.</p>
<p><strong>- Gọn: </strong>BREW được thiết kế ngay từ trong chíp nên các ứng dụng sẽ sử dụng ít bộ nhớ hơn nhưng lại tích hợp chặt chẽ hơn với các phần mềm hệ thống quan trọng của chíp để hỗ trợ thêm hàng loạt các tính năng từ việc quản lý các ứng dụng đến việc cho phép download trực tiếp từ điện thoại di động.</p>
<p><strong>- Có thể mở rộng:</strong> Như ứng dụng OpenGL để tạo nên những hình ảnh 3 chiều, hay cho phép các ứng dụng viết bằng Java có thể chạy được.</p>
<p><strong>- Phổ biến:</strong> BREW SDK cung cấp cung cấp những công cụ phát triển và gỡ lỗi, các ứng dụng mẫu kèm mã nguồn, những tài liệu tham tham khảo, bộ giả lập để mô phỏng. Tất cả đều có sẵn trên trang brew.qualcomm.com</p>
<p>Không những dễ dàng để phát triển, BREW còn là một hệ thống phân phối sản phẩm khép kín từ nhà phát triển cho đến người sử dụng cuối cùng. Có thể thấy như hình dưới:</p>
<p><em>- Sản phẩm được các nhà phát triển xây dựng.</em></p>
<p><em>- Ứng dụng được nhà cung cấp dịch vụ kiểm tra.</em></p>
<p><em>- Nhà cung cấp chọn các ứng dụng thoả mãn tiêu chuẩn, thoả thuận giá với nhà phát triển.</em></p>
<p><em>- Các ứng dụng được chọn sẽ được đưa vào catalog và gửi đến khách hàng.</em></p>
<p><em>- Khách hàng chọn ứng dụng và hình thức thanh toán.</em></p>
<p><em>- Khách hàng trả tiền.</em></p>
<p><em>- Nhà cung cấp nhận tiền, thanh toán cho nhà phát triển</em></p>
<p>Ở Việt Nam, một thị trường mới và có tốc độ phát triển viễn thông cũng như công nghệ thông tin rất cao, BREW sẽ đem lại nhiều loại nhuận cho các nhà cung cấp ứng dụng cũng như các nhà phát triển.Và bây giờ với sự ra đời của trung tâm phát triển 3G-CDMA, một tổ chức được thành lập theo thoả thuận giữa Qualcomm và Hà nội Telecom, một phòng thí nghiệm BREW hiện đại theo đúng tiêu chuẩn quốc tế sẽ đi vào hoạt động, đây sẽ là nơi để những nhà phát triển của Việt nam tìm hiểu, xây dựng, kiểm tra các ứng dụng. Cùng với sự phát triển mạnh mẽ của các mạng di động và các dịch vụ trên mạng, BREW sẽ ngày càng phát triển và đi vào đời sống ở Việt Nam</p>
<p>QUALCOMM’s Binary Runtime for Wireless Environment® (BREW™) cung cấp một nền tảng vững chắc nhằm tạo ra những ứng dụng hấp dẫn cho các thiết bị di động.</p>
<p>Qua bài giới thiệu này bạn sẽ thấy quen thuộc và thân thiện hơn với môi trường lập trình  <a href="http://www.thienlong.org/forumvn/showthread.php?t=8982" target="_blank">BREW</a>. Bài giới thiệu sẽ đi từng bước từng bước cẩn thận từ cài đặt BREW SDK, phát triển những ứng dụng BREW, và các nạp những ứng dụng vào trong thiết bị.</p>
<p><strong>BREW SDK</strong></p>
<p>Hiện nay đã có 5 phiên bản của BREW SDK: 1.0, 1.1, 2.0, 2.1, và 3.1. Các phiên bản này bạn cài đặt trực tuyến tại trang chủ của BREW. Việc lựa chọn từng phiên bản phụ thuộc vào nền tảng phần cứng và yêu cầu trong ứng dụng của bạn. Có thể các thiết bị sẽ không được hỗ trợ tất cả giao diện (interface) bên trong SDK.<br />
Để chắc chắn tương thích với các thiết bị di động, bạn nên thực hiện việc phát triển trong cùng hay những phiên bản SDK thấp để nhằm phù hợp với các phiên bản của BREW trong các phần cứng.</p>
<p><strong>BREW SDK 1.0</strong></p>
<p>Hiện tại không có thiết bị BREW 1.0 nào có trên thị trường. Những thiết bị bày bán trước đây có thực hiện BREW 1.0 chủ yếu là Motorola V731 và Sharp Z800.<br />
Những bổ sung API trong BREW SDK 1.0<br />
IApplet: đem lại qui trình xử lý sự kiện. Mọi ứng dụng BREW phải tiến hành giao diện này.<br />
IAStream: đem lại một giao diện trừu tượng để đọc dữ liệu từ một dòng không đồng bộ.<br />
IBase: đem lại giao diện nền cho mọi giao diện BREW AEE khác, đem lại cơ chế đếm tham khảo đối tượng.<br />
IControl: đem lại một giao diện trừu tượng được thực hiện bởi mọi giao diện kiểm soát BREW<br />
IDatabse: cho phép truy cập và điều chỉnh các hồ sơ cơ sở dữ liệu từ các file cơ sở dữ liệu do IDBMgr mở hoặc tạo ra.<br />
IDateCtl: đem lại một giao diện kiểm soát để lựa chọn và hiển thị ngày tháng theo một số định dạng<br />
IDBMgr: mở hoặc tạo các file cơ sở dữ liệu cho việc điều chỉnh thông qua IDatabase<br />
IDBRecord: truy cập và điều chỉnh các trường của các hồ sơ cơ sở dữ liệu<br />
IDialog: xử lý các đoạn thoại được tạo ra thông qua IShell<br />
IDisplay: điều chỉnh hiển thị của thiết bị bằng văn bản, biểu đồ bit, và những dạng hình học đơn giản khác<br />
IFile: cho phép việc tiếp cận và điều chỉnh các file do IFileMgr mở hoặc tạo ra<br />
IFileMgr: mở hoặc tạo các file cho việc điều chỉnh thông qua IFile<br />
IGraphics: bổ sung khả năng vẽ những đường và hình phức tạp hơn so với những hình và đường do IDisplay trợ giúp<br />
IHeap: quản lý bộ nhớ thiết bị và cung cấp các qui trình phân phối/hủy phân phối và thông tin sử dụng bộ nhớ<br />
IImage: thực hiện trợ giúp cho việc vẽ các định dạng hình ảnh khác nhau trên màn hình<br />
IMemAStream: tạo một tài nguyên dòng không đồng bộ từ một phần của bộ nhớ<br />
IMenuCtl: cung cấp đường truy cập tới nhiều bộ điều khiển chung lập theo ý người sử dụng<br />
IModule: cung cấp một cơ chế điều khiển đường truy cập tới một nhóm các ứng dụng nhỏ hay bộ phận đi kèm<br />
INetMgr: cấu hình các tham số đi kèm với hệ phụ mạng của một thiết bị di động<br />
INotifier: được các ứng dụng nhỏ sử dụng để thông báo các sự kiện xảy ra trong các lớp khác<br />
IShell: cho phép truy cập vào nhiều loại dịch vụ cấp thấp do điện thoại cung cấp<br />
ISocket: giao quyền kiểm soát để quản lý và sử dụng các ổ cắm TCP và UDP được mở thông qua INetMgr<br />
ISound: cho phép sự truy cập đến nhưng dịch vụ âm thanh căn bản, chẳng hạn như tiếng bíp và những tiếng rung<br />
ISoundPlayer: trợ giúp việc chơi lại các định dạng audi đã đi trước<br />
IStatic: được dùng để tạo và hiển thị những bộ kiểm soát văn bản tĩnh với văn bản không điều chỉnh được<br />
ITAPI: hình thành giao diện với lớp chức năng truyền thoại để truy cập các dịch vụ thoại và SMS<br />
ITextCtl: cung cấp lối nhập văn bản và các khả năng biên tập<br />
ITimeCtl: kiểm soát cho nhiều định dạng về đầu vào giá trị thời gian<br />
IViewer: cung cấp chức năng tương tự như giao diện IImage</p>
<p><strong>BREW SDK 1.1</strong></p>
<p>BREW 1.1 có lượng người sử dụng đông và ổn định lâu năm, với các thiết bị liên tục có sẵn trên thị trường của các thiết bị BREW 1.1. Một số trong những thí dụ nổi bật trong loại này là Motorola T-720 và LGE VX4400.</p>
<p><strong>Những bổ sung API</strong></p>
<p>IAddrBook: cung cấp một giao diện để tương tác với các khả năng sách địa chỉ OEM của thiết bị cầm tay<br />
IAddrRec: tạo thuận tiện cho việc truy cập và điều chỉnh các trường trong khuôn khổ các hồ sơ địa chỉ phục hồi được qua IAddrBook<br />
ICipher: cho phép các ứng dụng dễ dàng mã hóa và giải mã thông tin<br />
IGetLine: cung cấp nhưng phương pháp cho phép việc phân tách dòng của dữ liệu từ các nguồn</p>
<p>IHash: cung cấp đường truy cập tới các qui trình phân chia dữ liệu<br />
IHtmlViewer: trợ giúp việc chuyển giao một tập hợp con của HTML 3.2<br />
ILicense: cho phép các ứng dụng hỏi thăm thông tin về giấy phép riêng của chúng, và điều chỉnh số đếm giấy phép dựa trên việc sử dụng<br />
IPeek: thực hiện chức năng Peek/Advance cho việc tích lũy dữ liệu trong một bộ đệm</p>
<p>IPosDet: cấp phát đường truy cập vào các dịch vụ xác định vị trí bằng cách sử dụng thông tin bộ phận hay GSP<br />
IQueryInterface: lớp đối tượng cấp cho việc dẫn xuất những lớp đối tượng API có thể mở rộng được<br />
IRingerMgr: vận hành các thư mục thay thế trong thiết bị cầm tay, cho phép tạo lập và hủy bỏ những file thay thế<br />
IRSA: trợ giúp việc mã hóa dữ liệu bằng cách sử dụng thuật giải RSA<br />
ISource: một nguồn dữ liệu trừu tượng cung cấp giao diện Read/Readable (đọc/có thể đọc)<br />
ISourceUtil: được sử dụng để xây dựng một ISource từ các nguồn thường dùng<br />
IWeb: tạo điều kiện tiến hành những trao đổi web bằng cách sử dụng nhiều giao thức khác nhau<br />
IWebOpts: cho phép những tùy chọn cấu hình khiến các giao dịch IWeb được minh định</p>
<p><strong>Các bổ sung tiện dụng SDK</strong></p>
<p>Purevoice Converter: ứng dụng này cho phép chuyển đổi các file audio (âm thanh) từ WAV sang định dạng Purevoice của Qualcomm (QCP). Về các tính năng sử dụng, xin xem Hướng dẫn sử dụng BREW, được kèm trong tài liệu BREW SDK User có trong phiên bản từ BREW SDK 3.0 về sau, hoặc dưới dạng một tài liệu biệt lập trong các phiên bản SDK trước đó.</p>
<p><strong>BREW SDK 2.0</strong></p>
<p>Những thiết bị tiêu biểu trong loại này là LGE VX6000, Kyocera SE7 (Slider), và  <a href="http://www.thienlong.org/forumvn/showthread.php?p=71640#post71640" target="_blank">Samsung</a> SCH-A670.</p>
<p><strong>Các bổ sung API</strong></p>
<p>IBitmap: vận hành các biểu đồ bit nằm trong bộ nhớ, tạo điều kiện cho những hoạt động đồ hoạ đơn giản và chuyển khối bit<br />
IBTAG: được dùng để mở, đóng, và quản lý  <a href="http://www.thienlong.org/forumvn/showthread.php?t=10526" target="_blank">Bluetooth</a> Audio Gateway (cổng nghe công nghệ không dây Bluetooth) với một thiết bị (đã bị lược bỏ trong SDK 3.0)<br />
IBTSDP: cho phép tìm ra thiết bị Bluetooth và dò tìm thông tin về thiết bị (đã bị lược bỏ trong SDK 3.0)<br />
IBTSIOPORT: cung cấp bộ quản lý đường nối giao diện Bluetooth theo chuỗi và các dịch vụ chuyển dữ liệu (đã bị lược bỏ trong SDK 3.0)<br />
IClipboard: cung cấp đường truy cập vào các chức năng cắt và dán bảng trích giữ theo chuẩn<br />
IDIB: thực hiện một cấu trúc biểu đồ bit độc lập đối với thiết bị, kế thừa từ IBitmap (đã bị lược bỏ trong SDK 3.0)<br />
IDNS: cho phép dò hỏi DNS (server tên vùng)<br />
IFont: bổ sung các chức năng để vẽ và đo lường văn bản<br />
IHashCTX: cho phép tính chức năng lớn hơn trong việc phân cắt dữ liệu<br />
IImageCtl: cho phép hiển thị một hình ảnh trong khuôn khổ một khung hình có thể cuộn được<br />
IMedia: lớp trừu tượng cho mọi đối tượng đa phương tiện BREW<br />
IRamCache: đem lại một LRU bắt với cơ chế TTL cho việc lưu trữ  vùng heap<br />
ISprite: chứa các phương pháp để chuyền các hoạt cảnh và biểu đồ<br />
ISSL: trợ giúp an toàn SSL/TLS cho việc nối mạng<br />
ITransform: cung cấp các chức năng để thực hiện các hoạt động chuyền khối bit với những biến đổi chuyển dạng bằng cách dùng một biểu đồ bit<br />
IUnzipAStream: thực hiện trợ giúp cho việc giải nén và đọc các IAStream nén<br />
IVocoder: lập giao diện với bộ vocoder (mã hóa thoại) của thiết bị cầm tay để đón nhận và trình bày các khung vocoder<br />
IX509Chain: được dùng để quản lý và xác minh một chuỗi những chứng nhận X.509</p>
<p><strong>Những bổ sung ích dụng SDK</strong></p>
<p>2Bit Tool: tạo điều kiện chuyển đổi giữa các định dạng BMP 4-bit và 2-bit vì mục đích biên tập. Về các tính năng sử dụng, xin tham khảo Hướng dẫn sử dụng BREW, được kèm trong tài liệu BREW SDK User có trong phiên bản từ BREW SDK 3.0 về sau, hoặc dưới dạng một tài liệu biệt lập trong các phiên bản SDK trước đó.<br />
NMEA Logger: Cho phép truy tìm hoạt động GSP đã được ghi lại từ một thiết bị GNSS hoặc GPS để dùng trong Bộ mô phỏng Emulator. Về các tính năng sử dụng, xin xem Hướng dẫn sử dụng BREW, được kèm trong tài liệu BREW SDK User có trong phiên bản từ BREW SDK 3.0 về sau, hoặc dưới dạng một tài liệu biệt lập trong các phiên bản SDK trước đó.</p>
<p><strong>BREW SDK 2.1</strong></p>
<p>Thiết bị tiêu biểu trong loại này là Toshiba CDM-9900.</p>
<p>Các bổ sung API trong BREW SDK 2.1</p>
<p>I3D: cung cấp các xác định của một bộ máy đồ hoạ 3D để chuyển thanh những dạng tam giác (đã bị lược bỏ trong SDK 3.0)<br />
I3DModel: trợ giúp việc vẽ các nhóm tam giác có cấu trúc (các mẫu 3D) (đã bị lược bỏ trong SDK 3.0)<br />
I3DUtil: cho phép truy cập vào các ma trận chuyển hóa và các vector đơn vị được dùng bởi guồng máy 3D (đã bị lược bỏ trong SDK 3.0)<br />
ICallHistory: cấp phát sự truy cập và điều chỉnh cho các hồ sơ lịch sử cuộc gọi<br />
ICamera: cho phép một giao diện tiêu chuẩn hóa để truy cập máy ghi hình trên một thiết bị di động và các phương tiện ghi chép trong nhiều định dạng khác nhau<br />
ILogger: cung cấp một giao diện nhập dữ liệu được tiêu chuẩn hóa cho việc nhập bằng cách sử dụng nhiều loại cơ chế chuyển tải<br />
IMediaUtil: trợ giúp trong việc tạo ra các đối tượng IMedia từ nhiều nguồn đầu vào khác nhau và việc mã hóa các file truyền thông mới<br />
IRecordStore: lớp trừu tượng cho việc truy cập các kho lưu trữ giá trị khóa đơn giản.</p>
<p><strong>BREW SDK 3.0</strong></p>
<p>Hiện trên thị trường không có sẵn thiết bị BREW 3.0, tuy chúng được dự trù tung ra trong sáu tháng cuối năm 2004.</p>
<p><strong>Các bổ sung API trong BREW SDK 3.0</strong></p>
<p>IAClockCtl: cho phép việc tạo ra các hiển thị đồng hồ analog<br />
IBitmapDev: được dùng bởi nhiều chức năng khác nhau để xử lý các biểu đồ bit của thiết bị<br />
IModule Support: cung cấp các dịch vụ trợ giúp module cho các module đã nạp<br />
IPort: giao diện tổng quát cho dòng dữ liệu hai chiều thực hiện những giao diện chung<br />
IRscPool: cho phép bộ nhớ và tập hợp giao diện cho nhiều nguồn lực có tuổi thọ như nhau<br />
IThread: cung cấp khả năng thực hiện xử lý đa phương hợp tác</p>
<p>Các lược bỏ API trong BREW SDK 3.0</p>
<p>I3D<br />
I3DModel<br />
I3DUtil<br />
IBTAG<br />
IBTSDP<br />
IBTSIOPORT<br />
IDIB</p>
<p><strong>Thư mục cài đặt</strong></p>
<p>Nói chung để tốt nhất cho quá trình cài đặt cũng như phát triển về sau,thì tốt nhất bạn nên cài đặt theo mặc định của bộ cài đặt (BREW SDK Installer). Việc thay đổi thư mục cài đặt không ảnh hưởng đến ứng dụng nhưng đôi khi (những phiên bản 1.x) bạn sẽ mất thời gian để cấu hình lại Emulator khi chạy ứng dụng.</p>
<p><strong>Yêu cầu hệ thống</strong></p>
<p>+ Internet Explorer 5.5 Service Pack 2.<br />
+ Windows NT, Windows 2000, hoặc Windows XP.<br />
+ Quyền quản trị (hay quyền được cài đặt) trên hệ thống.</p>
<p>BREW SDK chỉ duy nhất cài đặt trên hệ điều hành Windows.<br />
<strong> <a href="http://www.thienlong.org/forumvn/showthread.php?t=8982" target="_blank">BREW</a> HỖ TRỢ NHÀ PHÁT TRIỂN TỪ ĐẦU ĐẾN CUỐI</strong></p>
<p>Từ khi có ý tưởng cho đến lúc thanh toán, QUALCOMM cam kết giúp đỡ nhà phát triển thành công bằng cách cung cấp sự hỗ trợ và nguồn tài nguyên trong toàn bộ quá trình.</p>
<p>Chương trình liên minh của nhà phát triển BREW là một chương trình đào tạo hội viên nhiều lớp, giúp nhà phát triển trong suốt quá trính sáng tạo và tiếp thị các ứng dụng vô tuyến. Những thành viên đã đăng ký “Chương trình liên minh của nhà phát triển BREW” có thể sử dụng “Extranet của nhà phát triển BREW”, nơi họ sẽ tìm được nhiều công cụ và nguồn tài nguyên bổ ích hơn.</p>
<p>Ngoài ra, các nhà phát triển có thể truy cập vào Chương trình đào tạo nhà phát triển BREW, một khóa học nâng cao trong ba ngày về thực hành, thiết kế để giúp nhà phát triển hiểu rõ kiến thức cơ bản về nền tảng BREW, hàng lọat các công cụ phát triển được sử dụng.</p>
<p><strong>NHỮNG ỨNG DỤNG VỮNG CHẮC TẠO RA DOANH THU </strong></p>
<p>Từ khi có BREW của QUALCOMM ra đời từ năm 2001, ĐTDD, sử dụng ứng dụng BREW, trở nên quá thanh nhã. Bỡi vì BREW đã xây dựng, phát trỉển và triển khai nhanh những ứng dụng sáng tạo, giải trí bổ ích, từ đó đem tới doanh thu cho nhà khai thác và nhà phát triển thông tin di động ngày càng nhiều thông qua những dịch vụ sau:</p>
<p><strong>TRUYỀN THÔNG:</strong> Nhắn tin tức thời, email, chia sẻ ảnh và những bộ trình duyệt.</p>
<p><strong>DỊCH VỤ ĐỊNH VỊ:</strong> Bản đồ, chỉ hướng, giao thông, hướng dẫn trong thành phố, v.v…</p>
<p><strong>NĂNG SUẤT: </strong>Đồng bộ hóa di động cho ứng dụng văn phòng và công cụ giúp cho năng suất cá nhân.</p>
<p><strong>KINH DOANH: </strong>Văn phòng di động, tự động hóa lực lượng hiện trường, tự động hóa lực lượng bán hàng của nhân viên di động, và nhiều họat động khác nữa.</p>
<p><strong>GAME:</strong> Game một người chơi và nhiều người chơi tương tác với nhau.</p>
<p><strong>THƯƠNG MẠI DI ĐỘNG:</strong> Những thương vụ tài chính như kết số tài khoản, điểm mua bán và giao dịch chứng khoán.</p>
<p><strong>GIẢI TRÍ: </strong>Nhạc chuông, âm nhạc, video, hình nền, hình của trình bảo vệ màn hình, kịch hài, v.v….</p>
<p><strong>THÔNG TIN: </strong>Tin tức, thể thao, thời tiết.</p>
<p><strong>MỞ RỘNG:</strong> Mở rộng công nghệ bên thứ ba mạnh mẽ cho nền BREW, như máy ảo Java hoặc bộ dữ liệu XML mà nhà phát triển có thể mở rộng cho ứng dụng của họ.</p>
<p><strong>BREW LÀ CÁ NHÂN:</strong> Đối với người tiêu dùng, BREW là không thể thấy được, mặc dầu nó hỗ trợ một kinh nghiệm mua sắm ứng dụng siêu nhanh và trực giác. Việc truy cập “cửa hàng trực tuyến” BREW là dễ dàng. Từ đó, các thuê bao có thể mua những ứng dụng, với giá cả ghi trên nhãn rõ ràng, trực tiếp từ ĐTDĐ của họ.</p>
<p><strong>MỤC TIÊU ỨNG DỤNG, TIẾN TRÌNH KINH DOANH</strong></p>
<p>Để thành công trong việc kinh doanh, ta cần có một giải pháp trọn vẹn xử lý được yêu cầu của mọi thiết bị &#8211; chứ không chỉ thiết bị cao cấp. Môi trường thực thi của ứng dụng BREW đã làm được điều này nhờ vào việc BREW tích hợp được với con chip xử lý trong bộ nhớ <a href="http://www.thienlong.org/forumvn/showthread.php?s=da8095d9cf9039b9cf00dd6cc69a2f9c&amp;t=10529#" target="_blank">Flash</a> và  <a href="http://www.thienlong.org/forumvn/showthread.php?s=da8095d9cf9039b9cf00dd6cc69a2f9c&amp;t=10529#" target="_blank">RAM</a> của thiết bị di động. Hơn nữa, BREW cung cấp một nối kết phần mềm giữa chức năng cấp thấp của thiết bị di động và ứng dụng cấp cao do người khác viết. Vì chức năng của BREW như là một lớp trừu tượng trong Flash và RAM, nên nhà phát triển phần mềm BREW không cần hiểu sâu về các hệ thống cài sẵn. Vì vậy, họ được tự do để tập trung vào thiết kế và sáng tạo các ứng dụng, chứ không phải vào phần cứng nền tảng.</p>
<p>Như thế, những lợi ích của giải pháp này là rất rõ: phát triển phần mềm hiệu quả và thuận tiện. Với BREW, nối kết ứng dụng từ thiết bị này sang thiết bị khác trở nên hầu như là chuyện vặt, thời gian xâm nhập thị trường được cắt giảm rất nhiều, và những ứng dụng mới hoạt động đồng bộ ở mọi điện thoại.</p>
<p>Ngoài ra, nền BREW còn thích hợp một cách lý tưởng với những điện thoại giá rẻ, vốn chiếm phần lớn thị trường hiện nay. Vì BREW chỉ đòi hỏi bộ nhớ khoảng 150k cho trọn hệ thống, nên các ứng dụng hữu ích và hấp dẫn nhỏ cỡ 10 tới 15k cho mỗi ứng dụng khách hàng, có thể được chào bán ở cấp thấp. Chi phí thấp và đơn giản cho sự tích hợp ở cấp vi mạch này, có nghĩa là BREW có thể phục vụ được hầu hết các thiết bị thuộc thị trường đại chúng. Hơn thế nữa, khách hàng dùng điện thoại di động chiếm nhiều phân khúc thị trường &#8211; từ khách sử dụng &#8220;an toàn&#8221; rất quan tâm tới giá cả với những thiết bị cầm tay rẻ tiền cho đến những khách hàng công ty với những thiết bị cao cấp, và từ những người trẻ tuổi tìm kiếm những dịch vụ giải trí sử dụng những thiết bị cầm tay trả trước cho đến các tay ngao du quốc tế với chi phí khổng lồ hàng tháng. Một công nghệ thành công phải giải quyết được mọi phân khúc khách hàng, và BREW đã làm được chuyện này.</p>
<p>Tóm lại, có lẽ điều quan trọng nhất là kể từ tháng 5 – 2002, 16 nhà khai thác mạng và dịch vụ di động, hầu hết các vận hành mạng đã công khai bày tỏ sự ủng hộ đối với BREW &#8211; họ có 16 triệu khách thuê bao trên toàn cầu và con số này đang ngày một gia tăng đáng kể. Các nhà phân phối hàng đầu như, Verizon Wireless và ALLTEL ở Mỹ, KDDI ở Nhật Bản và KTF ở Hàn Quốc đã tạo được những khoản thu nhập trên đầu tư và đang trông đợi những khoản thu nhập cao hơn trong tương lai từ các dịch vụ dữ liệu vô tuyến.</p>
<p>Các nhà phân phối khác, như Telstra của Úc, China Unicom và Vivo (liên doanh giữa Telefonica Moviles và Portugal Telecom) ở Brazil đang triển khai những sản phẩm và dịch vụ dựa trên BREW trong vài tuần nữa, thay vì vài năm nữa. Thời gian là tiền, và giải pháp BREW, có thêm BDS, tạo ra con đường đem lại lợi nhuận trong ngành công nghiệp vô tuyến.</p>
<p><em>Phạm Nhật Anh &#8211; BRDC<br />
Brewvietnam</em></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xrain.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xrain.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xrain.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xrain.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xrain.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xrain.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xrain.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xrain.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xrain.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xrain.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xrain.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xrain.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xrain.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xrain.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xrain.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xrain.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xrain.wordpress.com&amp;blog=3567475&amp;post=4&amp;subd=xrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xrain.wordpress.com/2008/04/25/tim-hi%e1%bb%83u-v%e1%bb%81-brew-tren-di%e1%bb%87n-tho%e1%ba%a1i-di-d%e1%bb%99ng-cdma/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c4777157d40cda711fb9d6630c4d8668?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xrain</media:title>
		</media:content>

		<media:content url="http://vimes.com.vn/images/stories/CLBIT/brew_logo.gif" medium="image">
			<media:title type="html">Image</media:title>
		</media:content>
	</item>
	</channel>
</rss>
