Monday, January 31, 2011
HTTP (Hypertext Transfer Protocol)
How can two computers share data?
What sets the connection between two computers on a network?
What is the actual form of the data sent over the Internet?
A computer network is a collection of two or more computers linked together for the purposes of sharing information, resources, among other things. The Internet, for example, is a global system of interconnected computer networks. While surfing the net, your computer sends and receive data over the internet two and from other computers.
Just like humans, two computers need a common "language" to talk to each other, a form of predefined rules to send and receive data. The protocol in which two computers are "speaking" is call The Internet Protocol (or IP).
Information is sent over the internet (using the IP) has the form of "Packets" - a basic transfer unit consists of header and data areas, where the header contains information about the sender and the destination computer and the data field contains the information to deliver.
As you see, beside the data, the protocol contains more information. Most of the other information describes the data so the receiver will "know" how to handle the content it gets.
IP uses its application layer protocols for describing the content. Lots of transformation protocol exist, for example the File Transfer Protocol (FTP) is a standard network protocol used to transfer files from one host to another over a network. The most used protocol over the internet is the HTTP protocol.
HTTP - Hypertext Transfer Protocol
HTTP functions as a request-response protocol in the client-server computing model. A typical "conversation" using this protocol evolved a web browser that acts as the client, while an application running on a computer hosting a web site functions as a server. The client submits an HTTP request message to the server. The server, which stores content, or provides resources, such as HTML files, or performs other functions on behalf of the client.
Example Request:
GET [ the path to the content - a URI] HTTP/1.1
HOST: [the server domain]
Connection: keep-alive
Referrer: [the caller - that initiated the HTTP call]
* This kind of HTTP call will find its way to the requested server that suppose to return the requested data. The response, of course, also has predefined format.
Example Response:
HTTP/1.1 200 OK -- the status of the response
Date: [the response date time]
Cache-Control: [the cache period of the returned data]
Server: [the server name - like: Microsoft-IIS/7.0]
Connection: close -- Indicates that the TCP connection closed
Connection-Length: [the length of the returned data - in bytes]
Content-Type: [html, script, xml etc.]
Response Data:
HTML, Javascript, JSON etc.
So, (and maybe the most important part :) ) - when you write an HTTP address i the address bar, like http://www.challengenes.com, you ask a server to give you the information this address contains. The information in this case has the form of HTML, those, the browser draws it inside your browser screen.
Enjoy.
Microsoft Windows Internet Services (WinInet)
the HTTP layer used by Internet Explorer, Microsoft Office, and many other products
Http debugging proxy
Monitoring interaction between the web browser and your web application i svery important
http://msdn.microsoft.com/en-us/library/Bb250446.aspx
http://msdn.microsoft.com/en-us/library/Bb250446.aspx
Sunday, January 30, 2011
JavaScript Data Types
JavaScript is a loosely typed language. You do not have to specify data types of a variable when you declare it. Data types are converted automatically as needed during script execution.
However, this is not good coding. Lets see an example:
var a = "20"; // string
var b = 30; // number
var c = a + b;
variable c contains the string "2030" and not 50 as expected.
For this reason (and many more) you should create variables for a specific type, such as an numbers, string, or boolean, and be consistent in the values that you store in the variable.
Although loosely typed, JavaScript contains six data types:
Three primitive types:
1. Number - 64bit floating point number. JavaScript does't distinguish between Integer and fraction. Every number is ... just a number.
2. String - sequence of Unicode characters quoted using the ' or " characters.
3. Boolean - true or false.
Special values:
4. null
5. undefined
Everything else:
6. object
Note that all of them defined using "var" and can be reset dynamically:
var str = "Hello World"; // string
var num = 20; // number
// changing type
str = num;
alert(str); // output: 20
Everything else in JavaScript is an object: functions, dates, regular expressions etc.
However, this is not good coding. Lets see an example:
var a = "20"; // string
var b = 30; // number
var c = a + b;
For this reason (and many more) you should create variables for a specific type, such as an numbers, string, or boolean, and be consistent in the values that you store in the variable.
Although loosely typed, JavaScript contains six data types:
Three primitive types:
1. Number - 64bit floating point number. JavaScript does't distinguish between Integer and fraction. Every number is ... just a number.
2. String - sequence of Unicode characters quoted using the ' or " characters.
3. Boolean - true or false.
Special values:
4. null
5. undefined
Everything else:
6. object
Note that all of them defined using "var" and can be reset dynamically:
var str = "Hello World"; // string
var num = 20; // number
// changing type
str = num;
alert(str); // output: 20
Everything else in JavaScript is an object: functions, dates, regular expressions etc.
Subscribe to:
Posts (Atom)