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中。

CocoaAsyncSocket 套接字的更多相关文章

  1. Linux Socket 原始套接字编程

    对于linux网络编程来说,可以简单的分为标准套接字编程和原始套接字编程,标准套接字主要就是应用层数据的传输,原始套接字则是可以获得不止是应用层的其他层不同协议的数据.与标准套接字相区别的主要是要开发 ...

  2. c 网络与套接字socket

    我们已经知道如何使用I/O与文件通信,还知道了如何让同一计算机上的两个进程进行通信,这篇文章将创建具有服务器和客户端功能的程序 互联网中大部分的底层网络代码都是用C语言写的. 网络程序通常有两部分组成 ...

  3. WebSocket异常 通常每个套接字地址(协议/网络地址/端口)只允许使用一次

    websocket的实例:http://blog.csdn.net/for_cxc/article/details/51500185 问题: 新建一个连接通信没有问题,但是如果关闭再建立就会报错:通常 ...

  4. Apache报错信息之通常每个套接字地址(协议/网络地址/端口)只允许使用一次(could not bind to address 0.0.0.0:80)

    我们常常在执行 httpd –k restart 重启Apache时报错提示: (OS 10048)通常每个套接字地址(协议/网络地址/端口)只允许使用一次.  : AH00072: make_soc ...

  5. C++网络套接字编程TCP和UDP实例

    原文地址:C++网络套接字编程TCP和UDP实例作者:xiaojiangjiang 1.       创建一个简单的SOCKET编程流程如下 面向有连接的套接字编程 服务器: 1)  创建套接字(so ...

  6. 谢欣伦 - OpenDev原创教程 - 服务端套接字类CxServerSocket

    这是一个精练的服务端套接字类,类名.函数名和变量名均采用匈牙利命名法.小写的x代表我的姓氏首字母(谢欣伦),个人习惯而已,如有雷同,纯属巧合. CxServerSocket的使用如下(以某个叫做CSo ...

  7. Python黑帽编程2.8 套接字编程

    Python黑帽编程2.8 套接字编程 套接字编程在本系列教程中地位并不是很突出,但是我们观察网络应用,绝大多数都是基于Socket来做的,哪怕是绝大多数的木马程序也是如此.官方关于socket编程的 ...

  8. 探索UDP套接字编程

    UDP和TCP处于同一层网络模型中,也就是运输层,基于二者之上的应用有很多,常见的基于TCP的有HTTP.Telnet等,基于UDP有DNS.NFS.SNMP等.UDP是无连接,不可靠的数据协议服务, ...

  9. 【Python网络编程】利用Python进行TCP、UDP套接字编程

    之前实现了Java版本的TCP和UDP套接字编程的例子,于是决定结合Python的学习做一个Python版本的套接字编程实验. 流程如下: 1.一台客户机从其标准输入(键盘)读入一行字符,并通过其套接 ...

随机推荐

  1. hive(七)hive-运行方式、GUI接口、权限管理

    1.Hive运行方式: 命令行方式cli:控制台模式 脚本运行方式(实际生产环境中用最多) JDBC方式:hiveserver2 web GUI接口 (hwi.hue等)   1.1Hive在CLI模 ...

  2. linux crontab 常用时间设置

    时间格式 分钟 小时 日期 月份 周 命令 数字范围 0-59 0-23 1-31 1-12 0-7 echo "hello" >> abc.log 特殊字符的含义 * ...

  3. MVC – 5.MVC设计模式和.NetMVC框架

    MVC模式-设计模式 •控制器(Controller)- 负责转发请求,对请求进行处理. •视图 (View) - 界面设计人员进行图形界面设计. •模型 (Model)-业务逻辑.数据.验证规则.数 ...

  4. GUC-4 CopyOnWriteArrayList/CopyOnWriteArraySet

    /* * CopyOnWriteArrayList/CopyOnWriteArraySet : “写入并复制” * 注意:添加操作多时,效率低,因为每次添加时都会进行复制,开销非常的大.并发迭代操作多 ...

  5. 浅谈ES5和ES6继承和区别

    最近想在重新学下ES6,所以就把自己学到的,记录下加强下自己的理解 首先先简单的聊下ES5和ES6中的继承 1.在es5中的继承: function parent(a,b){ this a = a; ...

  6. mvc bundle的介绍及使用 转载自 http://www.ityouzi.com/archives/mvc-bundleconfig.html

    Asp.Net MVC4 BundleConfig文件合并.压缩,网站优化加速 浏览器在向服务器发送请求的时候,请求的文件链接数量是有限制的,如果页面文件少就没有什么问题了,如果文件太多就会导致链接失 ...

  7. Java多线程编程——wait()和notify()、notifyAll()

    1.源码 wait() notify() notifyAll()都是Object类中方法.源码如下所示: public final native void notify(); public final ...

  8. python每天定时发送短信脚本

    最近业务上需要每天解析txt文本或者excel文件,读取内容发送短信,发送的时间段可控,用python实现 安装pip依赖 pip install -r requirement.txt xlrd Py ...

  9. java switch

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha switch 是 开关:转换 的意思. 支持的数据类型 有 : 字节,字符,短整型,整型 ...

  10. luoguP4284 [SHOI2014]概率充电器 概率期望树形DP

    这是一道告诉我概率没有想象中那么难的题..... 首先,用期望的线性性质,那么答案为所有点有电的概率和 发现一个点的有电的概率来源形成了一个"或"关系,在概率中,这并不好计算... ...