Как делает коммуникацию между браузером, и веб-сервер происходят?

Корректное константой решение для указателя C/C++. Минимальные операции в цикле.

int IsPalindrome (const char *str)
{
    const unsigned len = strlen(str);
    const char *end = &str[len-1];
    while (str < end)
        if (*str++ != *end--)
            return 0;
    return 1;
}
40
задан David Victor 9 March 2011 в 22:07
поделиться

6 ответов

Hyper Text Transfer Protocol (HTTP) is a protocol used for transferring web pages (like the one you're reading right now). A protocol is really nothing but a standard way of doing things. If you were to meet the President of the United States, or the king of a country, there would be specific procedures that you'd have to follow. You couldn't just walk up and say "hey dude". There would be a specific way to walk, to talk, a standard greeting, and a standard way to end the conversation. Protocols in the TCP/IP stack serve the same purpose.

The TCP/IP stack has four layers: Application, Transport, Internet, and Network. At each layer there are different protocols that are used to standardize the flow of information, and each one is a computer program (running on your computer) that's used to format the information into a packet as it's moving down the TCP/IP stack. A packet is a combination of the Application Layer data, the Transport Layer header (TCP or UDP), and the IP layer header (the Network Layer takes the packet and turns it into a frame).

The Application Layer

...consists of all applications that use the network to transfer data. It does not care about how the data gets between two points and it knows very little about the status of the network. Applications pass data to the next layer in the TCP/IP stack and then continue to perform other functions until a reply is received. The Application Layer uses host names (like www.dalantech.com) for addressing. Examples of application layer protocols: Hyper Text Transfer Protocol (HTTP -web browsing), Simple Mail Transfer Protocol (SMTP -electronic mail), Domain Name Services (DNS -resolving a host name to an IP address), to name just a few.

The main purpose of the Application Layer is to provide a common command language and syntax between applications that are running on different operating systems -kind of like an interpreter. The data that is sent by an application that uses the network is formatted to conform to one of several set standards. The receiving computer can understand the data that is being sent even if it is running a different operating system than the sender due to the standards that all network applications conform to.

The Transport Layer

...is responsible for assigning source and destination port numbers to applications. Port numbers are used by the Transport Layer for addressing and they range from 1 to 65,535. Port numbers from 0 to 1023 are called "well known ports". The numbers below 256 are reserved for public (standard) services that run at the Application Layer. Here are a few: 25 for SMTP, 53 for DNS (udp for domain resolution and tcp for zone transfers) , and 80 for HTTP. The port numbers from 256 to 1023 are assigned by the IANA to companies for the applications that they sell.

Port numbers from 1024 to 65,535 are used for client side applications -the web browser you are using to read this page, for example. Windows will only assign port numbers up to 5000 -more than enough port numbers for a Windows based PC. Each application has a unique port number assigned to it by the transport layer so that as data is received by the Transport Layer it knows which application to give the data to. An example is when you have more than one browser window running. Each window is a separate instance of the program that you use to surf the web, and each one has a different port number assigned to it so you can go to www.dalantech.com in one browser window and this site does not load into another browser window. Applications like FireFox that use tabbed windows simply have a unique port number assigned to each tab

The Internet Layer

...is the "glue" that holds networking together. It permits the sending, receiving, and routing of data.

The Network Layer

...consists of your Network Interface Card (NIC) and the cable connected to it. It is the physical medium that is used to transmit and receive data. The Network Layer uses Media Access Control (MAC) addresses, discussed earlier, for addressing. The MAC address is fixed at the time an interface was manufactured and cannot be changed. There are a few exceptions, like DSL routers that allow you to clone the MAC address of the NIC in your PC.

For more info:

69
ответ дан 27 November 2019 в 01:07
поделиться

Ваш браузер сначала преобразовывает имя сервера через DNS в IP. Затем он открывает TCP-соединение с веб-сервером и пытается общаться через HTTP. Обычно это TCP-порт 80, но вы можете указать другой ( http: // server: portnumber ).

HTTP выглядит так:

После подключения он отправляет запрос, который выглядит так:

GET /site HTTP/1.0
Header1: bla
Header2: blub
{emptyline}

Например, заголовок может быть Авторизация или Диапазон . Подробнее см. здесь .

Затем сервер отвечает следующим образом:

200 OK
Header3: foo
Header4: bar

content following here...

Например, заголовок может быть Date или Content-Type . Подробнее см. здесь .

См. Википедию для HTTP для получения дополнительной информации об этом протоколе.

18
ответ дан 27 November 2019 в 01:07
поделиться

Your browser is sitting on top of TCP/IP, as the web is based on standards, usually port 80, what happens is when you enter an address, such as google.com, your computer where the browser is running on, creates packets of data, encapsulated at each layer accordingly to the OSI standards, (think of envelopes of different sizes, packed into each envelope of next size), OSI defines 7 layers, in one of the envelopes contains the source address and destination address(that is the website) encoded in binary.

As it reaches the 1st layer, in OSI terms, it gets transmitted across the media transmitter (such as cable, DSL).

If you are connected via ISP, the layered pack of envelopes gets transmitted to the ISP, the ISP's network system, peeks through the layered pack of envelopes by decoding in reverse order to find out the address, then the ISP checks their Domain Name System database to find out if they have a route to that address (cached in memory, if it does, it forwards it across the internet network - again layered pack of envelopes).

If it doesn't, the ISP interrogates the top level DNS server to say 'Hey, get me the route for the address as supplied by you, ie. the browser', the top level DNS server then passes the route to the ISP which is then stored in the ISP's server memory.

The layered pack of envelopes are transmitted and received by the website server after successful routing of the packets (think of routing as signposts for directions to get to the server), which in turn, unpacks the layered pack of envelopes, extracts the source address and says 'Aha, that is for me, right, I know the destination address (that is you, the browser), then the server packetizes the webpages into a packed layered envelopes and sends it back (usually in reverse route, but not always the case).

Your browser than receives the packetized envelopes and unpacks each of them. Then your computer descrambles the data and your browser renders the pages on the screen.

I hope this answer is sufficient enough for your understanding.

8
ответ дан 27 November 2019 в 01:07
поделиться

Связь между браузером и веб-сервером происходит на стольких уровнях, что ответить на этот вопрос практически невозможно. HTTP играет роль, но HTTP бессмысленен без TCP, который бессмыслен без IP, что бессмысленно без физической сети, по которой он отправляется. Кроме того, существуют запросы POST vs GET, которые похожи, но достаточно разные, чтобы потребовать специального обсуждения. Иногда HTTP-запрос должен быть аутентифицирован, иногда - нет. Следует упомянуть типы пантомимы. Затем браузер отправляет другой запрос, если есть прокси. И тогда тоже играют роль кодировки. Итак, я думаю, самый краткий ответ на этот вопрос: браузер запрашивает данные у сервера, а сервер передает запрашиваемые данные браузеру.

2
ответ дан 27 November 2019 в 01:07
поделиться

Существует коммерческий продукт с интересный логотип, который позволяет вам видеть все виды трафика между сервером и клиентом под названием charles .

Другие инструменты с открытым исходным кодом включают: Live HttpHeaders , Wireshark или Firebug .

3
ответ дан 27 November 2019 в 01:07
поделиться

Это зависит от веб-сервера, но если вам интересно, как он выглядит со стороны клиента, просто установите Live Headers и Firebug для firefox. При открытой вкладке net в заголовках firebug и live должно быть ясно, как именно они взаимодействуют.

Для более глубокого просмотра фактических данных, передаваемых туда и обратно, используйте wirehark .

4
ответ дан 27 November 2019 в 01:07
поделиться
Другие вопросы по тегам:

Похожие вопросы: