CocoaAsyncSocket 套接字

CocoaAsyncSocket   套接字

https://github.com/robbiehanson/CocoaAsyncSocket

 

Asynchronous socket networking library for Mac and iOS

用于iOS以及Mac的异步套接字网络库。

 

TCP

GCDAsyncSocket and AsyncSocket are TCP/IP socket networking libraries. Here are the key features available in both:

GCDAsyncSocket与AsyncSocket这两个是TCP/IP套接字网络库。以下是它们的特性:

  • Native objective-c, fully self-contained in one class.
    No need to muck around with sockets or streams. This class handles everything for you.

  • 原生的OC,完整的一个类,不需要你去染指sockets或者是流,这个类帮你搞定了所有的封装。
  • Full delegate support
    Errors, connections, read completions, write completions, progress, and disconnections all result in a call to your delegate method.

  • 完整的代理来支持Errors,链接,读操作,写操作,进度以及断开链接,所有的这些都在代理方法中调用。
  • Queued non-blocking reads and writes, with optional timeouts.
    You tell it what to read or write, and it handles everything for you. Queueing, buffering, and searching for termination sequences within the stream - all handled for you automatically.

  • 非阻塞队列读写,可以设置超时时间。你来决定什么时候读什么时候写,之后这个类来帮你搞定剩下的事情。入队、缓存、用流查询目的地序列都会自动的运行。
  • Automatic socket acceptance.
    Spin up a server socket, tell it to accept connections, and it will call you with new instances of itself for each connection.

  • 自动套接字接收。连接上服务器,告知它接受链接,之后,它会自己创建一个实例对象来维持这次链接。
  • Support for TCP streams over IPv4 and IPv6.
    Automatically connect to IPv4 or IPv6 hosts. Automatically accept incoming connections over both IPv4 and IPv6 with a single instance of this class. No more worrying about multiple sockets.

  • 支持IPv4以及IPv6的TCP流。自动连接IPv4或者IPv6的主机。自动接收来自IPv4或者IPv6的连接,只用一个实例对象,你不用担心重复的套接字。
  • Support for TLS / SSL
    Secure your socket with ease using just a single method call. Available for both client and server sockets.

  • 支持TLS/SSL,加密你的socket,只需调用一个方法,支持服务器或者客户机套接字。

GCDAsyncSocket is built atop Grand Central Dispatch:

GCDAsyncSocket基于GCD扩展出的:

  • Fully GCD based and Thread-Safe
    It runs entirely within its own GCD dispatchqueue, and is completely thread-safe. Further, the delegate methods are all invoked asynchronously onto a dispatch_queue of your choosing. This means parallel operation of your socket code, and your delegate/processing code.

  • 基于GCD以及完全的线程安全,它内置了GCD线程池。
  • The Latest Technology & Performance Optimizations
    Internally the library takes advantage of technologies such as kqueue's to limit system calls and optimize buffer allocations. In other words, peak performance.

AsyncSocket wraps CFSocket and CFStream:

AsyncSocket封装了CFSocket和CFStream:

  • Fully Run-loop based
    Use it on the main thread or a worker thread. It plugs into the NSRunLoop with configurable modes.
  • 基于Run-loop,在主线程或者一个其他线程中使用,它会用一些配置来插入到NSRunLoop中。

 

 

UDP

GCDAsyncUdpSocket and AsyncUdpSocket are UDP/IP socket networking libraries. Here are the key features available in both:

GCDAsyncUdpSocket和AsyncUdpSocket是UDP/IP套接字网络库。以下是它们的特性:

  • Native objective-c, fully self-contained in one class.
    No need to muck around with low-level sockets. This class handles everything for you.

  • 原生的OC,完整的一个类,不需要你去染指sockets或者是流,这个类帮你搞定了所有的封装。
  • Full delegate support.
    Errors, send completions, receive completions, and disconnections all result in a call to your delegate method.

  • 完整的代理来支持Errors,链接,读操作,写操作,进度以及断开链接,所有的这些都在代理方法中调用。
  • Queued non-blocking send and receive operations, with optional timeouts.
    You tell it what to send or receive, and it handles everything for you. Queueing, buffering, waiting and checking errno - all handled for you automatically.

  • 非阻塞队列读写,可以设置超时时间。你来决定什么时候读什么时候写,之后这个类来帮你搞定剩下的事情。入队、缓存、用流查询目的地序列都会自动的运行。
  • Support for IPv4 and IPv6.
    Automatically send/recv using IPv4 and/or IPv6. No more worrying about multiple sockets.

  • 支持IPv4以及IPv6的TCP流。自动连接IPv4或者IPv6的主机。自动接收来自IPv4或者IPv6的连接,只用一个实例对象,你不用担心重复的套接字。

GCDAsyncUdpSocket is built atop Grand Central Dispatch:

GCDAsyncUdpSocket基于GCD扩展出的:

  • Fully GCD based and Thread-Safe
    It runs entirely within its own GCD dispatchqueue, and is completely thread-safe. Further, the delegate methods are all invoked asynchronously onto a dispatch_queue of your choosing. This means parallel operation of your socket code, and your delegate/processing code.
  • 基于GCD以及完全的线程安全,它内置了GCD线程池。

AsyncUdpSocket wraps CFSocket:

AsyncUdpSocket封装了CFSocket:

    • Fully Run-loop based
      Use it on the main thread or a worker thread. It plugs into the NSRunLoop with configurable modes.
    • 基于Run-loop,在主线程或者一个其他线程中使用,它会用一些配置来插入到NSRunLoop中。

 

 

 

转载于:https://www.cnblogs.com/YouXianMing/p/3668405.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/377096.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

谷歌浏览器设置缓存方法

谷歌浏览器设置缓存方法: 1、在桌面Google Chrome快捷方式,目标:找到 C:\Users\Splendid\AppData\Local\…\Application\chrome.exe 在这后面加上-Disk-Cache-Dir”Z:\TEMP” 注意: -Disk前面有空格,”Z:\TEMP” 是文件存放在Z盘T…

《dp补卡——买卖股票问题》

目录121. 买卖股票的最佳时机贪心dp思路滚动数组优化122. 买卖股票的最佳时机 II123. 买卖股票的最佳时机 III188. 买卖股票的最佳时机 IV309. 最佳买卖股票时机含冷冻期714. 买卖股票的最佳时机含手续费121. 买卖股票的最佳时机 贪心 取最左最小值,取最右最大值&…

oo0ooo0ooo0oo_OoO的完整形式是什么?

oo0ooo0ooo0ooOoO:外出 (OoO: Out of Office) OoO is an abbreviation of "Out of Office". OoO是“不在办公室”的缩写。 It is an expression, which is commonly used in the Gmail platform. It is written in the body or the subject of the email…

SP2010开发和VS2010专家食谱--第三章节--高级工作流(2)--为沙盒解决方案创建自定义活动...

尽管沙河解决方案功能有限,你仍然可以开发自定义活动,在SharePoint Designer中使用而不用改变web.config或添加.ACTION文件到根文件夹。 转载于:https://www.cnblogs.com/crazygolf/p/3856795.html

sql where 1=1和 0=1 的作用

where 11; 这个条件始终为True,在不定数量查询条件情况下,11可以很方便的规范语句。 一、不用where 11 在多条件查询中的困扰 举个例子,如果您做查询页面,并且,可查询的选项有多个,同时,还让用户…

j@2ff4f00f_J4F的完整形式是什么?

j2ff4f00fJ4F:只是为了好玩 (J4F: Just For Fun) J4F is an abbreviation of "Just For Fun". J4F是“ Just For Fun”的缩写 。 It is an expression, which is commonly used in messaging or chatting on social media networking sites like Faceboo…

《dp补卡——子序列问题》

目录300. 最长递增子序列674. 最长连续递增序列718. 最长重复子数组1143. 最长公共子序列53. 最大子序和392. 判断子序列115. 不同的子序列583. 两个字符串的删除操作72. 编辑距离647. 回文子串 (与 5.最长回文子串思路差不多)516. 最长回文子序列300. 最…

[LeetCode] Maximal Rectangle

Given a 2D binary matrix filled with 0s and 1s, find the largest rectangle containing all ones and return its area. 在做 Largest Rectangle in Histogram的时候有人说可以用在这题,看了一下还真是,以每行为x轴,每列往上累计的连续的…

什么是alpha测试_什么是ALPHA?

什么是alpha测试Α (ALPHA) Alpha is the first and foremost letter of the Greek alphabet. In the classification of Greek numerals or numbers, it constitutes a value of 1. Alpha是希腊字母的第一个也是最重要的字母 。 在希腊数字或希腊数字的分类中,它的…

《leetcode : 647. 回文子串 思考分析双指针解法》

647. 回文子串 如何确定是回文串: 找中心然后往两边扩散,判断是否对称即可。 在遍历中心点的时候,注意中心点可以是一个元素也可以是两个元素。 class Solution { public:int cal_two_extend(const string& s,int i,int j,int n){int re…

天草初级班(3)

算术运算指令算术运算指令是反映CPU计算能力的一组指令,也是编程时经常使用的一组指令。它包括:加、减、乘、除及其相关的辅助指令。 该组指令的操作数可以是8位、16位和32位(80386)。当存储单元是该类指令的操作数时,该操作数的寻址方式可以…

4.3.3版本之引擎bug

bug描述:   IOS设备上,当使用WWW www WWW.LoadFromCacheOrDownload(url, verNum); 下载资源时,第一次下载某个资源,www.assetBundle必定为空。 解决办法:   引擎版本降到4.3.2或者升到4.3.4或更高。 这个bug绝对是…

sml完整形式_411的完整形式是什么?

sml完整形式411:信息 (411: Information) 411 is an abbreviation of “Information". 411是“信息”的缩写 。 It is an expression, which is commonly used in messaging or chatting on social media networking sites like Facebook, Yahoo Messenger, a…

php 检测用户是否关闭浏览器

1、例子1 echo str_repeat(" ",3000);ignore_user_abort(true); mylog(online);while (true) {/** 1、程序正常结束 connection_status 0* 2、点击浏览器“停止”按钮 connection_status 1* 3、超时 connection_status 2*/echo "test<br>\n&qu…

explain用法

explain用法 EXPLAIN SELECT …… 变体&#xff1a; 1. EXPLAIN EXTENDED SELECT …… 将执行计划“反编译”成SELECT语句&#xff0c;运行SHOW WARNINGS 可得到被MySQL优化器优化后的查询语句 2. EXPLAIN PARTITIONS SELECT …… 用于分区表的EXPLAIN 执行计划包含的信息 id…

《位运算技巧以及Leetcode的一些位运算题目》

目录技巧练习位运算[461. 汉明距离](https://leetcode-cn.com/problems/hamming-distance/)[190. 颠倒二进制位](https://leetcode-cn.com/problems/reverse-bits/)[136. 只出现一次的数字](https://leetcode-cn.com/problems/single-number/)[260. 只出现一次的数字 III](http…

linux读取配置文件(C语言版)

一个通用的linux系统中C语言版读取配置文件的函数。 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <errno.h>#define KEYVALLEN 100/* 删除左边的空格 */ char * l_trim(char * szOutput, con…

java 范围搜寻要怎么弄_搜索范围

java 范围搜寻要怎么弄Problem statement: 问题陈述&#xff1a; Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. 给定一个以升序排列的整数nums数组&#xff0c;请找到给定目标值的开始和结束…

boa + ajax + cgi ajax请求cgi

最近公司要做一个通讯管理机,然后需要和另外一个同事一起做,我们需要用到boaAjaxCGI,以前没试过与CGI交互,一开始发现问题挺大的,用ajax请求cgi,总是不返回数据,又或者请求回来的是cgi的源码,后来发现,通过本地IIS或者直接打开html页面请求的,返回来的都是cgi的源码或者返回失败…

《DBNotes:single_table访问方法、MRR多范围读取优化、索引合并》

目录single_table访问方法constrefref_or_nullrangeindexallMRR多范围读取优化索引合并intersectionunionsort-unionsingle_table访问方法 const 在主键列或者unique二级索引与一个常数进行等值比较时才有效。 如果主键或者unique二级索引的索引列由多个列构成&#xff0c;则…