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.pswp.cn/news/377096.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/377096.shtml
英文地址,請注明出處:http://en.pswp.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;則…