Pure-Swift Sockets. Linux & OS X ready.
TCP | UDP | |
---|---|---|
Client | ✅ | ✅ |
Server | ✅ | ✅ |
.Package(url: "https://github.com/czechboy0/Socks.git", majorVersion: 0, minor: 12)
The package provides two libraries: SocksCore
and Socks
.
SocksCore
is just a Swift wrapper of the Berkeley sockets API with minimal differences. It is meant to be an easy way to use the low level API without having to deal with Swift/C interop.Socks
is a library providing common usecases built on top ofSocksCore
- a simpleTCPClient
,SynchronousTCPServer
etc.
If you're building a HTTP server, you'll probably want to use the TCPClient
, without having to worry about its implementation details. However, if you need the low-level sockets API, just import SocksCore
and use that instead.
There are many working examples in this package which build as separate binaries.
- TCP client using SocksCore (SocksCoreExampleTCPClient)
- TCP server using SocksCore (SocksCoreExampleTCPServer)
- TCP server that keeps client connections alive using SocksCore (SocksCoreExampleTCPKeepAliveServer)
- TCP client using Socks (SocksExampleTCPClient)
- TCP server using Socks (SocksExampleTCPServer)
- UDP client using Socks (SocksExampleUDPClient)
- UDP server using Socks (SocksExampleUDPServer)
- (1) TCP/IP Sockets in C: Practical Guide for Programmers (First and Second edition)
- (2) Wikipedia: Berkeley Sockets
🔧 Used by
- Redbird Pure-Swift implementation of a Redis client from the original protocol spec. OS X + Linux compatible.
- Vapor A web framework and server for Swift that works on OS X and Ubuntu.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Please create an issue with a description of your problem or open a pull request with a fix.
MIT
Honza Dvorsky - http://honzadvorsky.com, @czechboy0
Matthias Kreileder - @matthiaskr1