Getting Started with iOS Network programming: Socket Programming in iOS

Source: Internet
Author: User
Tags socket

Using socket for C/s structure programming, connection process

The server side listens for a connection request on a port. The server-side program is blocked until the client issues a connection request to the server, and the server-side accepts the requestor to run down. Once the connection is established, the input output stream object can be obtained through the socket. Communication with the client can be achieved by means of an input-output stream object, and the last thing to do is to close the socket and release some resources (including: Turn off the input/output stream).

The client process specifies the server IP address, port, and transport protocol (TCP or UDP) to be communicated, a connection request is made to the server, and a connection is established after the server has an answer request. And then the server side is the same.

In iOS, there are three techniques available for client socket programming:

1 Use Nsstream. For the implementation of OBJECTIVE-C language, the API provided by the Foundation framework provided by Apple;

2 Use Cfstream. For C-language implementation, the core Foundation framework provided by Apple provides the API;

BSD Socket. Also called the Berkeley socket (Berkeley socket), is widely used in UNIX platform socket programming. It is for C language implementation, full use of C writing, use more trouble. It was developed by students at the University of California, Berkeley (University of California, Berkeley).

In iOS, server-side socket programming can be used in two different technologies:

1 Use Cfstream. For C-language implementation, the core Foundation framework provided by Apple provides the API;

2 BSD Socket. Also called the Berkeley socket (Berkeley socket), is widely used in UNIX platform socket programming. It is for C language implementation, full use of C written, use up more trouble. It was developed by students at the University of California, Berkeley (University of California, Berkeley).

This article is from the "Dongsheng" blog, please be sure to keep this source http://2009315319.blog.51cto.com/701759/1176604

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.