"Reading notes" iOS network-Inter-device communication using game kit

Source: Internet
Author: User

Apple's Game kit framework enables communication between devices and devices without network conditions, including without a cellular service, inability to access the Wi-Fi infrastructure, and inability to access the local area network or the Internet. For example, deep in the jungle, on highways or in the basement of buildings.

One, Game kit basics

In addition to the underlying network communication features, game Kit also includes games-specific technologies such as achievements, leaderboards and tournaments.

Although Bluetooth has a unique advantage over network infrastructure, there are some big flaws. The maximum connection range of 32 feet is much smaller than the Wi-Fi network, which can span multiple access points to cover a larger range. In a Wi-Fi network, the available bandwidth for each endpoint is nearly 10 times times that of Bluetooth. While Bluetooth radios are more power-saving than Wi-Fi, game kit still prefers Wi-Fi, not Bluetooth, if all the endpoints are connected by both types of access. While it is wrong to consider only one connection, it actually reduces the overall power consumption of the device. An iOS device connected to a Wi-Fi network uses that connection for all data requests in the background, such as periodic mail checks or push notifications. Because the radio will be used, the use of Bluetooth radios will actually increase power consumption.

All communications made through the game kit session are unencrypted. If the datagram's secrets are important to the application, for example, the mobile payment device transmits credit card information for registration, then the developer is responsible for encrypting the traffic before sending the data to gksession.

Two, point-to-point network

Under the connection of the point-to-point game kit, any endpoint in the network behaves as both a server and a client. In many cases, the same device switches between the client and server roles during the processing of the business process, but you can use a single peer connection without having to reconnect the device to the new role. Peer is also ideal for processes that do not know the endpoint role before the process starts.

1, connect to the session.

2. Send data to the endpoint.

1) The ARM processor used by the iOS device uses a small-endian byte order.

The big end and the small endian are two ways to represent a binary dataset. The endian byte order stores bytes from the most important to the least important order, while the small end byte order is the opposite. An example of a big-endian byte sequence is a telephone number, where the grouping of numbers is arranged from the most important (country code) to the least important (user number). The byte order originates from a hardware implementation that stores values in memory, and the goal of standardizing the network byte order is to prevent small-end machines from accidentally interpreting binary data stored in big endian bytes without knowing the need to convert. Big and small end these two names originate from Jonathon Swift's novel "Gulliver Travels", which describes two different ways of beating eggs.

Third, client-server communication

Four, summary

Game Kit has a unique role in the iOS ecosystem because it integrates Bluetooth to create a network of nearby devices. Its Wi-Fi capability is a simple package for Bonjour services, but the real advantage is that the same code base can be used to support both network technologies. Its innovative peer-to-peer model provides unprecedented flexibility for joining networks in applications, while the client-server model provides developers with a more familiar environment while improving stability.

Reference: "iOS network advanced programming-iphone and ipad Enterprise application Development"

"Reading notes" iOS network-Inter-device communication using game kit

Related Article

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.