Getting Started with iOS web Apps

Source: Internet
Author: User
Tags ftp transfer

As we all know, network application in the Internet era of importance, personal as a modern people in daily life basically inseparable from the network.

iOS network development This piece is undoubtedly a very important piece. Personally think it is more difficult to chew, to go back and forth to learn several times, or dizzy did not learn to understand, the following hope that by writing this study notes can deepen the understanding of network development.

The first time to write a blog, just to account for some learning and development ideas, please advise.

I. Common protocols in URLs

So what is a URL?

URL full name is Uniform Resource Locator (Consent Resource Locator), URL is unique, through a URL, can find the Internet only one resource.

Basic format of URL = protocol://HOST address/path

Protocol: Different protocols represent different methods of resource finding, resource transfer,

Here are a few common protocols

    1. The most commonly used protocol in network development: HTTP: Hypertext Transfer Protocol, access to remote network resources, the format is/HTTP/
    2. Accessing resources on the local computer: File protocol format: file://
    3. Access e-mail address: mailto format: mailto://
    4. To access a shared host's file resource: FTP format: ftp://
Host address: The IP address of the host where the resource exists

Path: The exact location of the resource in the host


Second, the HTTP protocol

Each blog forum has a lot of articles about HTTP, I this swim, you can go to the great God's blog to learn.

The following gives the Baidu Encyclopedia link, or self-access book Resources

Click to open link


My own understanding:

An HTTP connection is an application that is built on a TCP connection, and the HTTP connection uses a "request-response" approach not only to establish a connection at the time of the request, but also to require the client to reply to the client after the server has made a request, to automatically release the connection after the request has ended. This method saves transmission time and is a "short connection" to the socket.

So to expand: What is TCP, when it comes to TCP will definitely have UDP presence, which is likely to be asked by the interview.

    1. TCP: Transmission Control Protocol, which provides a connection-oriented, reliable byte stream service, which belongs to the Transport layer protocol. (For specific OSI layer seven and TCP/IP five, go to Wikipedia or the Great God blog)
    • Premise: Before the Client Access server exchanges data with each other, a TCP connection must be established between the two parties before the data can be transferred
    • Function: Provide time-out re-send, test data, flow control, feedback mechanism, to ensure that the data can be transmitted from one end to the other, ideally, once the TCP connection is established, the TCP connection will be maintained until either side of the communication is actively shutting down the connection, Both the server and the client can proactively initiate a request to disconnect a TCP connection
    • Purpose: TCP sends the packet has the serial number, the two sides receives the packet to give a feedback, if has not received the feedback to automatically perform the timeout resend after a certain time, therefore the TCP biggest advantage is reliable. Web http, mail SMTP, remote connection, file FTP transfer
    • Three-time handshake: Make a connection--send a request--and answer a request--end notification. Examples of phone calls:

      [Hello, Hello, can you hear me?] ]

      [No problem.] Can hear me say. ]

      [No problem.] ]

2.UDP: User Datagram Protocol, is a non-connected, simple datagram-oriented Transport layer protocol
    • Equivalent to TCP:

      Does not provide reliability, it simply sends the application to the IP layer's datagram, but does not guarantee that it will reach its destination.

      Because UDP does not have to establish a connection between the client and the server before transmitting the datagram, and there is no mechanism such as time-out retransmission, the transmission speed is fast

    • Purpose: UDP is a message-oriented protocol, communication does not need to establish a connection, the transmission of data is naturally unreliable, UDP is generally used for multipoint communication and real-time data services, such as voice broadcast, video, QQ, tftp Simple File transfer, SNMP Simple Network Management Protocol, RTP real-time transmission protocol, RIP Routing Information Protocol (such as reporting stock information, aviation information), DNS domain name interpretation. Focus on speed and fluency


The difference between a 3.Socket connection and an HTTP connection:

socket: Since the socket connection is usually a TCP connection, once the socket connection is established, the communication parties can start sending data content to each other until the two sides are disconnected.

In the actual application development, the client-to-server communication often needs to traverse multiple intermediary nodes, such as routers, gateways, firewalls, and so on, most firewalls will turn off a long inactive connection and cause the socket connection to be disconnected, so it needs to be polled to tell the network that the connection is active.

HTTP: HTTP protocol is an application based on TCP protocol, the HTTP connection uses "Request-response" method, not only need to establish a connection in the request, and require the client to make a request to the server, the server can reply to the data.

After the request is finished, the connection is released actively.

The process from establishing a connection to closing a connection is called a "one-time connection."

Because HTTP is actively releasing the connection after each request ends, the HTTP connection is a "short connection", which requires constant connection requests to the server to maintain the client program's online status.

The usual practice is that even if you do not need to obtain any data, the client also keeps sending a "keep-connected" request to the server at regular intervals, and the server responds to the client after receiving the request, indicating that the client is "online". If the server can not receive the client's request for a long time, it is considered that the client "offline", if the client cannot receive a reply from the server for a long time, the network has been disconnected

Usage scenarios: In many cases, the server needs to proactively push data to the client, keeping the client and server data in real time and in sync.

At this time, if the two sides established a socket connection, the server can directly transfer data to the client;

If the two sides establish an HTTP connection, the server needs to wait until the client sends a request to send the data back to the client, so the client periodically sends a connection request to the server, not only to remain online, but also to "ask" the server if there is new data, and if so, pass the data to the client

Socket principle

Socket (socket) is the cornerstone of communication and is the basic operating unit of network communication supporting TCP/IP protocol .

It is an abstract representation of the endpoint in network communication, contains five kinds of information that must be used for network communication : 1 protocol using the connection, 2 IP address of the local host, 3 protocol port for the local process, 4 IP address of the remote host, and 5 protocol port of the far process.

When the application layer communicates data through the transport layer, TCP encounters a problem that provides concurrent services for multiple application processes at the same time.

Multiple TCP connections or multiple application processes may require data to be transmitted over the same TCP protocol port. To differentiate between the different application processes and connections, the computer operating system provides the socket interface for the application to interact with the TCP/IP protocol. The application layer can communicate with the transport layer through the socket interface, differentiate the communication from different application processes or network connections, and realize the concurrent service of data transmission.

To establish a socket connection : A socket connection requires at least one pair of sockets, one running on the client, called Clientsocket, and the other running on the server side, called ServerSocket

The connection process between sockets is divided into three steps: Server listening, client request, connection acknowledgement

Server monitoring: Server-side sockets do not locate specific client sockets, but are waiting for the status of the connection, real-time monitoring network status, waiting for the client's connection request

Client request: The client socket requests a connection request, and the destination to connect to is the server-side socket. To do this, the client's socket must first describe the socket of the server it is connecting to, indicate the address and port number of the server-side socket, and then make a connection request to the server-side socket

Connection confirmation: When a server-side socket hears or receives a connection request from a client socket, it responds to a client socket request, establishes a new thread, sends a description of the server-side socket to the client, and once the client confirms the description, the two sides formally establish the connection. While the server-side socket continues listening, it continues to receive connection requests from other client sockets

Socket connection to TCP connection: When creating a socket connection, you can specify the transport layer protocol used, the socket can support different transport layer protocols (TCP or UDP), and when connected using the TCP protocol, the socket connection is a TCP connection




Getting Started with iOS Web apps

Contact Us

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

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

A Free Trial That Lets You Build Big!

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

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

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