Latest-ios sockets

Source: Internet
Author: User

Socket
    • Socket is also called "socket"
    • The two programs on the network realize the exchange of data through a two-way communication connection, one end of this connection is called a socket.
    • Applications typically make requests to the network via "sockets" or respond to network requests
Elements of network communication
    • The request on the network is to establish a connection through the socket and then communicate with each other
    • IP address (Unique identification of host devices on the network)
    • Port number (Locator)
      • The logical address used to mark the process, and the marking of the different processes
      • Valid ports: 0~65535, where 0~1024 is used by the system or reserved ports, it is recommended to use more than 1024 ports in development
    • Transport protocol (how to interact)
      • Rules of Communication
      • Common protocols: TCP, UDP
Transport protocol: TCP&UDP
    • TCP (Transmission Control Protocol)

      • Establish a connection to form a channel for transmitting data
      • Large data transfer in the connection (no limit to the information)
      • Complete connection via three handshake, reliable protocol, secure delivery
      • The connection must be established and the efficiency will be slightly lower
    • UDP (User Datagram Protocol)

      • Encapsulates data and sources and purposes into packets without establishing a connection
      • Limit the size of each datagram within 64K
      • Because there is no connection, it is an unreliable protocol
      • No need to establish connection, fast speed
Socket Communication flowchart
Socket communication flowchart. png

Add:
1.HTTP the bottom is the connection through the socket to establish a communication pipeline to achieve data transmission
2.HTTP is a TCP Transport protocol (mode), it is a reliable, secure protocol

Implement the Socket monitoring method

(1) Using C language to implement,
(2) using the cocoaasyncsocket third box, the interior is a C package

    • telnet command telnet host port/telnet 192.168.10.10 5288
      • The 1.telnet command is a service that corresponds to a port on the connection server
Protocol on the socket Layer
    • The protocol on the socket layer refers to the format of the data transfer
    • HTTP protocol
      Transport format: Suppose: This is the assumption that the actual HTTP format is not the case.
      http1.1,content-type:multipart/form-data,content-length:188,body:username=zhangsan&password=123456
    • XMPP protocol, an Instant messaging protocol

      • Extensible Message Processing Field Protocol) is an Extensible Markup Language (XML)-based protocol that is used for instant messaging (IM) and on-line on-site probing. This agreement may eventually allow Internet users to send instant messages to anyone else on the internet
    • Transfer format:

      <from>zhangsan<from>
      <to>lisi<to>

      <body> eat together at night </body>

    • Custom Instant Messaging protocol, JSON format

      {
      "From": "Zhangsan",
      "To": "Lisi",
      "Body": "Eat Lunch Together"
      }



Latest-ios sockets

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.