gitmyhub

CocoaAsyncSocket

Objective-C ★ 12k updated 22d ago

Asynchronous socket networking library for Mac and iOS

CocoaAsyncSocket is a networking library for macOS, iOS, and tvOS that simplifies sending and receiving data over TCP and UDP connections with a thread-safe, non-blocking API.

Objective-CCocoaPodsCarthageSwift Package Managersetup: moderatecomplexity 3/5

CocoaAsyncSocket is a networking library for macOS, iOS, and tvOS that handles sending and receiving data over a network connection. Networking code in Apple platforms can be verbose and error-prone when written from scratch; this library wraps the low-level details in two simple classes so developers can focus on what data to send rather than how to send it.

The library provides two main classes. GCDAsyncSocket handles TCP connections, which is the type of networking used by most applications that need reliable, ordered delivery of data (web requests, chat, file transfers). GCDAsyncUdpSocket handles UDP, which is used for faster, lower-overhead communication where occasional lost packets are acceptable (live audio, games, streaming). Both classes are built on Grand Central Dispatch, Apple's system for running work concurrently, making them non-blocking and thread-safe.

Key capabilities listed in the README include queued reads and writes (you tell the library what you want sent or received and it handles buffering), automatic handling of both IPv4 and IPv6 addresses, built-in support for TLS and SSL encryption (the same protocol used for HTTPS), and automatic acceptance of incoming connections for server-side use.

The library is written in Objective-C but works in Swift apps through a standard import. It can be added to a project via CocoaPods, Carthage, or Swift Package Manager, or by copying source files directly. The README notes a wiki for developers new to how networking sockets actually behave.

The license is public domain, meaning the code can be used in any project without restriction.

Where it fits