CocoaAsyncSocket README

The project's README from github.com/robbiehanson/CocoaAsyncSocket. As one markdown file: README.md.

CocoaAsyncSocket

Build Status Version Status Carthage compatible Platform license Public Domain

CocoaAsyncSocket provides easy-to-use and powerful asynchronous socket libraries for macOS, iOS, and tvOS. The classes are described below.

Installation

CocoaPods

Install using CocoaPods by adding this line to your Podfile:

use_frameworks! # Add this if you are targeting iOS 8+ or using Swift
pod 'CocoaAsyncSocket'  

Carthage

CocoaAsyncSocket is Carthage compatible. To include it add the following line to your Cartfile

github "robbiehanson/CocoaAsyncSocket" "master"

The project is currently configured to build for iOS, tvOS and Mac. After building with carthage the resultant frameworks will be stored in:

Select the correct framework(s) and drag it into your project.

Swift Package Manager

Simply add the package dependency to your Package.swift and depend on "CocoaAsyncSocket" in the necessary targets:

dependencies: [
    .package(url: "https://github.com/robbiehanson/CocoaAsyncSocket", from: "7.6.4")
]

Manual

You can also include it into your project by adding the source files directly, but you should probably be using a dependency manager to keep up to date.

Importing

Using Objective-C:

// When using Clang Modules:
@import CocoaAsyncSocket; 

// or when not:
#import "GCDAsyncSocket.h" // for TCP
#import "GCDAsyncUdpSocket.h" // for UDP

Using Swift:

import CocoaAsyncSocket

TCP

GCDAsyncSocket is a TCP/IP socket networking library built atop Grand Central Dispatch. Here are the key features available:

UDP

GCDAsyncUdpSocket is a UDP/IP socket networking library built atop Grand Central Dispatch. Here are the key features available:


For those new(ish) to networking, it's recommended you read the wiki.
Sockets might not work exactly like you think they do...

Still got questions? Try the CocoaAsyncSocket Mailing List.


Love the project? Wanna buy me a ☕️  ? (or a 🍺  😀 ):

donation-bitcoin donation-paypal

CocoaAsyncSocket (robbiehanson/CocoaAsyncSocket)

Searching Database…

这是什么?CocoaAsyncSocket 是一个异步套接字网络库,适用于 macOS、iOS 和 tvOS,基于 Grand Central Dispatch 提供 TCP 和 UDP 类。
这是完整的框架,还是我只要拖进几个类就行?它是一个轻量级库,主要由两个独立的 Objective-C 类组成:用于 TCP 的 GCDAsyncSocket 和用于 UDP 的 GCDAsyncUdpSocket,并不是完整的框架。
我该怎么把它加入项目?可以通过 CocoaPods、Carthage 或 Swift Package Manager 添加依赖来安装,也可以直接手动把源文件拖进项目。
除了 Xcode,使用它还需要别的东西吗?它可以直接用 Objective-C 或 Swift 导入使用,并依赖已内置于 Apple SDK 中的 GCD,无需任何外部运行时依赖。
套接字在这里的行为有什么需要注意的地方吗?README 本身提醒,套接字的工作方式不一定符合新手的预期,建议在深入使用前先阅读项目 wiki。
它同时支持 IPv4 和 IPv6 吗?支持。TCP 和 UDP 类都能自动支持 IPv4 和 IPv6 连接,无需为它们分别创建套接字。
它能在哪些 Apple 平台上运行?它可以为 macOS、iOS 和 tvOS 构建。
GCDAsyncSocket 支持加密连接吗?支持。它只需一次方法调用即可启用 TLS/SSL,客户端和服务端套接字均可使用。
它如何处理线程和回调?它完全在自己的 GCD 调度队列中运行,并且是完全线程安全的;委托方法会异步地在你指定的调度队列上调用,以实现并行操作。
我启动一个服务端套接字时会发生什么?GCDAsyncSocket 支持自动接受连接:你只需让它开始接受连接,每有一个新连接进来,它就会为该连接生成一个新的自身实例,并调用你的委托。
Size
2.2 MB
Stars
12.4K
Age
14y
Commits · 90 Days