Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux.
APACHE-2.0 License
Bot releases are visible (Hide)
Published by dannys42 about 3 years ago
Published by dannys42 over 3 years ago
Published by dannys42 over 3 years ago
This release no longer supports Swift 4.x. The minimum supported Swift version is 5.0, while the minimum recommended version is 5.2.
Published by billabt almost 5 years ago
Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux.
swift-4.0.0-RELEASE
toolchain (Minimum REQUIRED for latest release)swift-5.0-RELEASE
toolchain (Recommended)Published by billabt over 6 years ago
Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux.
swift-4.0.0-RELEASE
toolchain (Minimum REQUIRED for latest release)swift-4.2-RELEASE
toolchain (Recommended)Published by billabt almost 8 years ago
This release minimally requires use of the swift-3.1.1-RELEASE toolchain or the swift-4.0.0-RELEASE toolchain which is recommended.
read(into data: inout Data)
- This function reads all the data available on a socket and returns it in the Data
object that was passed. This function has been added to the SocketReader protocol.write(from data: Data)
- This function writes the data contained within the Data
object to the socket. This method has been added to the SocketWriter protocol.remoteConnectionClosed
, to enable differentiation between a socket that is no longer connected to its' remote partner and one that would block. If this property returns true, the remote connection has been closed and the socket should be closed.README.md
.endianness check
for host before byte swapping (PR#20).Signature
. Hence, the caller would not know what port was assigned and is being listened to. Added two additional unit tests to test this condition. Also, related to this, passing of a zero (0) for port when attempting to connect
is invalid and will now be cause for an exception being thrown.README.md
for more information.isSecure
, at the Socket
level to resolve the optional signature
property and returns true if the socket is secure and false otherwise.README.md
for more information.README.md
for more information.truncate
parameter. See issue #66.Published by billabt about 8 years ago
This release requires use of the swift-DEVELOPMENT-SNAPSHOT-2016-08-15-a toolchain.
README.md
for more information.read(into data: inout Data)
- This function reads all the data available on a socket and returns it in the Data
object that was passed. This function has been added to the SocketReader protocol.write(from data: Data)
- This function writes the data contained within the Data
object to the socket. This method has been added to the SocketWriter protocol.Published by billabt about 8 years ago
This release requires use of the swift-DEVELOPMENT-SNAPSHOT-2016-08-04-a toolchain or the new swift-DEVELOPMENT-SNAPSHOT-2016-08-07-a toolchain. The use of the 8/7 toolchain is recommended.
README.md
for more information.read(into data: inout Data)
- This function reads all the data available on a socket and returns it in the Data
object that was passed. This function has been added to the SocketReader protocol.write(from data: Data)
- This function writes the data contained within the Data
object to the socket. This method has been added to the SocketWriter protocol.Published by billabt about 8 years ago
This release requires use of the new swift-DEVELOPMENT-SNAPSHOT-2016-07-25-a toolchain.
read(into data: inout Data)
- This function reads all the data available on a socket and returns it in the Data
object that was passed.write(from data: Data)
- This function writes the data contained within the Data
object to the socket.Published by billabt over 8 years ago
This release requires use of the new swift-DEVELOPMENT-SNAPSHOT-2016-06-20-a toolchain.
Published by billabt over 8 years ago
5/03, 5/31 or 6/06 DEVELOPMENT
release of the toolchain.make*()
API's with create()
(various forms depending on what you're creating). To create a socket using default parameters, use create()
.class
to struct
.FD
class and changed names to look more familiar with their 'C' counterparts. i.e. FD_SET
in C becomes FD.SET
in Swift.Published by billabt over 8 years ago
3/16 DEVELOPMENT
release of the toolchain.import BlueSocket
you should now use:
import Socket
Parent | Old Property/Function Signature | New Property/Function Signature |
---|---|---|
SocketReader | readData(data: NSMutableData) throws -> Int | read(into data: NSMutableData) throws -> Int |
SocketWriter | writeData(data: NSData) throws | write(from data: NSData) throws |
SocketWriter | writeString(string: String) throws | write(from string: String) throws |
Socket.Address | Not available | var size: Int |
Socket.Address | func toAddr() -> sockaddr | var addr: sockaddr |
Socket.Signature | public var addrSize: Int | Removed now part of Socket.Address. |
Socket.Error | Conforms to ErrorType | Conforms to ErrorProtocol |
Socket | var connected: Bool | var isConnected: Bool |
Socket | var listening: Bool | var isListening: Bool |
Socket | var remoteHostName: String? | var remoteHostname: String |
Socket | var remotePort: Int | var remotePort: Int32 |
Socket | N/A | var isServer: Bool |
Socket | N/A | var listeningPort: Int32 |
Socket | class func defaultConfigured() throws -> BlueSocket | class func makeDefault() throws -> Socket |
Socket | class func customConfigured(family: ProtocolFamily, type: SocketType, proto: SocketProtocol) throws -> BlueSocket | class func makeConfigured(family family: ProtocolFamily, type: SocketType, proto: SocketProtocol) throws -> Socket |
Socket | class func createConnected(Signature signature: Signature) throws -> BlueSocket | class func makeConnected(using signature: Signature) throws -> Socket |
Socket | class func createUsing(NativeHandle socketfd: Int32, address: Address?) throws -> BlueSocket | class func makeFrom(nativeHandle nativeHandle: Int32, address: Address?) throws -> Socket |
Socket | class func ipAddressStringAndPort(fromAddress: Address) -> (hostname: String, port: Int)? | class func hostnameAndPort(from address: Address) -> (hostname: String, port: Int32)? |
Socket | class func checkStatus(sockets: [BlueSocket]) throws -> (readables: [BlueSocket], writables: [BlueSocket]) | class func checkStatus(for sockets: [Socket]) throws -> (readables: [Socket], writables: [Socket]) |
Socket | func acceptConnectionAndKeepListening() throws -> BlueSocket | func acceptClientConnection() throws -> Socket |
Socket | func connectTo(host: String, port: Int32) throws | func connect(to host: String, port: Int32) throws |
Socket | func connectUsing(Signature signature: Signature) throws | func connect(using signature: Signature) throws |
Socket | func listenOn(port: Int) throws | func listen(on port: Int) throws |
Socket | func listenOn(port: Int, maxPendingConnections: Int) throws | func listen(on port: Int, maxPendingConnections: Int) throws |
Socket | func readData(buffer: UnsafeMutablePointer, bufSize: Int) throws -> Int | func read(into buffer: UnsafeMutablePointer, bufSize: Int) throws -> Int |
Socket | func readData(data: NSMutableData) throws -> Int | func read(into data: NSMutableData) throws -> Int |
Socket | func writeData(buffer: UnsafePointer, bufSize: Int) throws | func write(from buffer: UnsafePointer, bufSize: Int) throws |
Socket | func writeData(data: NSData) throws | func write(from data: NSData) throws |
Socket | func writeString(string: String) throws | func write(from string: String) throws |
Socket | func setBlocking(shouldBlock: Bool) throws | func setBlocking(mode shouldBlock: Bool) throws |
Published by billabt over 8 years ago
Bug fixes:
Published by billabt over 8 years ago
Some major refactoring of the code internals that makes the API a bit more easier to use:
Additionally, added code to allow listening sockets to avoid dying from a SIGPIPE signal for an interrupted connection.
Published by billabt over 8 years ago
What's changed in this release:
swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a
drop of the Swift toolchain. Use of this drop or higher is REQUIRED
.gethostbyname()
since it's obsolete and replaced it with the more modern getaddrinfo().sockaddr
, sockaddr_in
, sockaddr_in6
and sockaddr_storage
to facilitate conversions based on the protocol family.BlueSocket.dottedIP(fromAddress:)
class method with a new more robust BlueSocket.ipAddressStringAndPort(fromAddress:)
that returns an optional tuple containing both the string representation of the hostname and the port based on the pass socket address info.signature
property.BlueSocketSignature
, BlueSocket.createConnected(Signature:)
. Accompanying that, added an instance function, connectUsing(Signature:)
, that allows connection to be achieved by providing a BlueSocketSignature
object.BlueSocketSignature
to make it easier to use the new class function to create a connected socket all in one step.Published by billabt over 8 years ago
Beginnings of support for UDP. Not yet available.
Published by billabt over 8 years ago
Added new class function to check the readability/writability of an array of BlueSockets.
Published by billabt over 8 years ago