Brew SDK's nine functions-Network Services

Source: Internet
Author: User
Tags file transfer protocol

Brew can implement main network functions through isocket and inetmgr. From the network perspective, socket is a virtual interface between applications on different hosts, with cross-platform features. From the programmer's point of view, socket is an interface for applications and network devices, special I/O. There are three types of sockets: stream sockets, datav sockets, and Internet Protocol only, this interface is used to directly access the raw sockets of the IP protocol ). Socket interfaces are not limited to TCP/IP, but are almost equivalent to TCP/IP because of its wide application.

An important concept in network services is IP Address/Domain Name. Brew can use the gethostbyaddr and getaddrbyhost functions to convert each other. Another important concept is the port number. TCP and UDP use 16-bit port numbers to identify applications. The server is generally identified by the accept port number. For example, the TCP port number of the FTP server is 21, and the UDP port number of the TFTP (simple File Transfer Protocol) server is 69. The port number is used to distinguish different applications. rfc1700 specifies the port list defined by IANA (an Internet-allocated number authority). The port number is divided into three sections: accept port: 0 ~ 1023, allocated and controlled by IANA, unavailable to common users; registered port: 1024 ~ 49151, not controlled by IANA, but the IANA registers and provides a list of their usage; dynamic or private ports: 49152 ~ 65535, IANA regardless of the port, also known as the temporary port. Theoretically, the port value that can be used for programming is 1024 ~ 65535. The root permission is required to use a universal port.

The Brew isocket is derived from the standard BSD socket and adopts the non-blocking asynchronous communication mode. The callback function-based notification method supports TCP and UDP (brew2.x mobile phones support at least three TCP at the same time, 4 UDP ). Inetmgr supports IPv4 and PPP network attributes and manages network behavior. It is the initiator of all isocket and is released after all operations are completed. The isocketport and inetwork in brew 3.x and later versions support a variety of mobile communication networks and IPv6 functions.

The isocket interface is responsible for specific network connections. Each connection requires an isocket interface. The isocket interface cannot be directly created, but should be created through inetmgr_opensocket. Therefore, without an inetmg instance, The isocket cannot work. Inetmgr_opensocket is used to open a TCP or UDP socket. If the call succeeds, the function returns a pointer to the isocket interface instance. You can use this pointer to call isocketconnect to specify the target IP address and port number of the socket to be connected. After the first socket is connected to the device, brew aee will build a network subsystem. The sub-system consists of the CDMA physical layer, the wireless link protocol (RLP) of the CDMA device, and the Point-to-Point Protocol (PPP) connection. All sockets connected to the device will share these connections. You can call isocketrelease to close the socket. When the last Socket connected to the device is closed, brew aee terminates the connection to the network subsystem after the specified delay.

The advantage of non-blocking network communication in brew is that it avoids the failure to respond to system events in a timely manner due to long running of any user thread, and at the same time brings a little processing trouble, that is, the client program may not be able to take the data from the specified port as soon as the UDP packet arrives, as a result, data packets that are not read in time on the same port will be overwritten by subsequent data packets. Pay attention when designing applications. In TCP/IP, the maximum length (MSS, maximum segment size) is used to indicate the maximum length of block data transmitted by TCP to the other end. Therefore, understanding the MSS value on the wireless network makes sense for the development of network applications, especially the streaming media service. Setting the size of each frame to the MSS allowed by TCP can ensure the network utilization and reduce the overhead of the TCP header.

For a wide range of Internet services, brew provides a series of iWeb interfaces that allow developers to conveniently use the Internet and provide Web Proxy functions. The Brew Web Proxy specification is easy to use and is a fixed string ending with null, similar to common URL syntax. The brewweb proxy specification can be used to specify multiple proxy specifications for a processing task and tested in the iwebopts_getopt () sequence. They have a set of simple but effective syntaxes that can be used to specify the inclusion and exclusion of proxy URLs. The Brew Web Proxy specification does not need to be replicated and can be managed as webopts.

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/wireless_com/archive/2010/04/07/5456697.aspx

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.