BlueSocket

Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux.

APACHE-2.0 License

Stars
1.4K
Committers
33

Bot releases are hidden (Show)

BlueSocket - Eliminate some compiler warnings Latest Release

Published by dannys42 about 3 years ago

BlueSocket - Include update for cocoapods

Published by dannys42 over 3 years ago

BlueSocket - 2.0.0

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.

BlueSocket - Version 1.0

Published by billabt almost 5 years ago

Version 1.0

Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux.

Prerequisites

Swift

  • Swift Open Source swift-4.0.0-RELEASE toolchain (Minimum REQUIRED for latest release)
  • Swift Open Source swift-5.0-RELEASE toolchain (Recommended)
  • Swift toolchain included in Xcode Version 10.2 (10E125) or higher.

macOS

  • macOS 10.11.6 (El Capitan) or higher.
  • Xcode Version 9.0 (9A325) or higher using one of the above toolchains.
  • Xcode Version 10.2 (10E125) or higher using the included toolchain (Recommended).

iOS

  • iOS 10.0 or higher
  • Xcode Version 9.0 (9A325) or higher using one of the above toolchains.
  • Xcode Version 10.2 (10E125) or higher using the included toolchain (Recommended).

Linux

  • Ubuntu 16.04 (or 16.10 but only tested on 16.04 and 18.04).
  • One of the Swift Open Source toolchains listed above.

Other Platforms

  • BlueSocket is NOT supported on watchOS since POSIX/BSD/Darwin sockets are not supported on the actual device although they are supported in the simulator.
  • BlueSocket should work on tvOS but has NOT been tested.

Add-ins

  • BlueSSLService can be used to add SSL/TLS support.
    • If using this package, please note that the libssl-dev package is required to be installed when building on Linux.

Changes since 1.0.0

  • When calling getaddrinfo(), the hints variable should reflect the protocol family of the socket.
  • Added new parameter to connect() to allow the caller to force the connection to the specific family of the Socket instance making call. The default behavior is to allow connection to any socket family.
  • Big endian fixes. PR #130.
  • Update to Swift 4.1.
  • Fixed connect() for UDP sockets. PR #137.
  • Added CI support for Swift 4.2 builds. PR #138.
  • Improve using Signature to connect to socket. PR #147.
  • Update to use Swift 4.2 as default. PR #151.
  • Resolve Swift 5 compilation warnings. Drop Swift 3 support. PR #154.
  • Added new parameter to TCP version of listen API to allow caller to specify a particular address to listen on. This new parameter is defaulted to nil and therefore should NOT affect current callers.
  • Update the example in the README to correct a data race condition. Issue #115.
  • Update CI support to use Swift 4.2.3. PR #169
  • Update for Swift 5.0. PR #170.
  • Add CI support for Xcode 11.
  • Fixed problem with endianess on big iron. PR #177.
  • Update to use Swift 5.1 as default.
BlueSocket - Version 1.0

Published by billabt over 6 years ago

Version 1.0

Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux.

Prerequisites

Swift

  • Swift Open Source swift-4.0.0-RELEASE toolchain (Minimum REQUIRED for latest release)
  • Swift Open Source swift-4.2-RELEASE toolchain (Recommended)
  • Swift toolchain included in Xcode Version 10.0 (10A255) or higher.

macOS

  • macOS 10.11.6 (El Capitan) or higher.
  • Xcode Version 9.0 (9A325) or higher using one of the above toolchains.
  • Xcode Version 10.0 (10A255) or higher using the included toolchain (Recommended).

iOS

  • iOS 10.0 or higher
  • Xcode Version 9.0 (9A325) or higher using one of the above toolchains.
  • Xcode Version 10.0 (10A255) or higher using the included toolchain (Recommended).

Linux

  • Ubuntu 16.04 (or 16.10 but only tested on 16.04).
  • One of the Swift Open Source toolchain listed above.

Other Platforms

  • BlueSocket is NOT supported on watchOS since POSIX/BSD/Darwin sockets are not supported on the actual device although they are supported in the simulator.
  • BlueSocket should work on tvOS but has NOT been tested.

Add-ins

Changes since 1.0.0

  • When calling getaddrinfo(), the hints variable should reflect the protocol family of the socket. See issue #128.
  • Added new parameter to connect() to allow the caller to force the connection to the specific family of the Socket instance making call. The default behavior is to allow connection to any socket family. See issues #129 and #128.
  • Added support for big endian devices. PR #130.
  • Added descriptive error messages for internal errors. PR #131.
  • Update for Swift 4.1.
  • Fixed minor warnings on Linux.
  • Fixed problem with connect() when using UDP sockets. PR #137.
  • Update to include Swift 4.2 in CI builds.
  • Added prerequisite that the libssl-dev package is required to be installed when building on Linux if using the BlueSSLService add-in.
  • Minor license update.
  • Performance fix for debug mode. PR #144.
  • Added test for issue #139.
  • connect using signature changes. PR #147.
  • Updates for Xcode 10 to project.
  • Swift 4.2 support.
  • Fixed buffer overflow problem that only showed up in optimized code. Issue #139.
  • Make Swift 4.2 the default compiler in project.
  • Update for Swift 4.2 (PR #151) and Xcode 10.
  • Added CI support for building with Swift 5. PR #154.
  • Added new parameter to TCP version of listen API to allow caller to specify a particular address to listen on. This new parameter is defaulted to nil and therefore should affect current callers.
BlueSocket - Swift 4 Support.

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.

  • Compatible with Xcode 9.0 (9A235) General Release or higher using one of the above toolchains.
  • Added support for arm architecture for FD utilities.
  • Added nine (9) new tests to test suite including a full test server helper function that uses Dispatch.
  • Added 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.
  • Added 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.
  • Merged in support for non-blocking writes to TCP sockets per PR#15 submitted against the legacy-0.7 branch. Also available at tag 0.7.6 for use with the 7/25 toolchain.
  • See README.md for more information about the new API.
  • Added new property, 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.
  • APIs based on NSData and NSMutable data will be deprecated in a future release.
  • Removed verifyConnection() function from SSLServiceDelegate protocol. Now handled internally by SSLService itself.
  • Minor change to initialize delegate function of SSLServiceDelegate. SSLService.inititalize(isServer:) became SSLService.initialize(asServer:).
  • Updated example in README.md to use multi-threaded Dispatch based API.
  • Added continuous integration (PR#16) include build badge in README.md.
  • Allow use on iOS, tvOS and watchOS as well as macOS.
  • Added endianness check for host before byte swapping (PR#20).
  • Added fix for issue #22. When requesting to listen on port 0, the port assigned by the OS was not being returned in the 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.
  • Added support for using UNIX Domain Sockets. See the README.md for more information.
  • Read and write function can now throw a SOCKET_ERR_CONNECTION_RESET exception in the event the connection was reset by the peer.
  • Added new computed property, isSecure, at the Socket level to resolve the optional signature property and returns true if the socket is secure and false otherwise.
  • Updated tests to account for serverHelper launch and take down.
  • Added UDP support. See the README.md for more information.
  • Fixed issue #46.
  • Fixed issue #959 from Kitura.
  • Fixed a crash bug revealed in BlueSSLService issue #10.
  • Fixed issue #49. File representing a UNIX socket should not be deleted when a client socket is closed. Only the listening socket should delete the file.
  • Fixed issue #50.
  • Added documentation (as a result of issue #53) that documents how to set the socket read buffer size.
  • Changed how certain flags were being reset during the close of a socket. Related to issue #53. Also removed old debug statement and redundant memory clearing calls.
  • Merged PR #54 to correct warnings under Swift 3.1.
  • Merged PR #55 to correct memory leaks related to getAddrInfo.
  • In response to issue #56, added two new functions that allow the setting of a read and/or write timeout. See the README.md for more information.
  • Merged PR #57 to add CocoaPod support.
  • Added usage information for CocoaPods.
  • Merged PR #60 which now allows port sharing between IPV6 and IPV4 sockets.
  • When the SSLServiceDelegate is set to a non-nil value, increase the read buffer size to accommodate the TLS packet size. Related to issue #22 in BlueSSLService.
  • Added code to validate the port values passed to connect(to:port:) function and ensure they fall within the proper range.
  • Merged PR #61: Set SO_REUSEPORT for port sharing on macOS.
  • Merged PR #62.
  • Corrected buffer overflow problem when doing certain TCP reads the use the truncate parameter. See issue #66.
  • Changed podpsec Swift version to 3.1.1.
  • Update podspec to include watchOS and tvOS. PR #70
  • Support of Xcode 9 Beta.
  • Support for ALPN in SSLServiceDelegate. PR #67
  • Merge PR #72 to fix problem reported by issue #68.
  • Fixed issue #81, If the attempt to set the SO_REUSEPORT socket option fails, check errno for ENOPROTOOPT and if set, silently ignore the error. This can happen when using WSL (Windows Subsystem for Linux).
  • Added new utility function, udpBroadcast, to allow enablement and disablement of broadcast mode for UDP sockets. This fixes issue #80.
  • Fixed bug in new utility function, udpBroadcast, that was causing the inverse of what it was supposed to do.
  • Added enhancement to connect API to allow for a connection timeout (issue #65). See the documentation in the README.md for how to use the new API.
  • Swift 4 Support.
  • Merged PR #85 to allow deferral of SSL accept. This fixes BlueSSLService issue #40. For more details and discussion refer to that issue.
  • Fixed bug related to PR #85.
  • Removed watchOS support. See issue #87 for more info.
  • Fixed problem on macOS when using connect API. See issue #88 for more info.
  • Update FD* functions to consistently used Int32 where appropriate.
  • Allow wait() function to be called on UDP sockets that are bound.
  • Add new parameter for listen() API that allows the caller to decide whether to reuse the listening port or not. Default behavior is to reuse the port. Resolves issue #94.
  • Removed unsafe access to Socket.Address, PR #93.
  • Corrected some outdated documentation in README.md, issue #96.
  • Added tvOS target to Xcode project, issue #100.
  • Minor project changes for tvOS.
  • Remove build on Xcode 8.3.
  • CI updates.
  • Clarify use of the isReadableOrWritable() function when attempting to write to a newly connected socket. Issue #105.
  • Cleanup and minor bug fix. PR #107.
  • Rolled back fd_set extension from PR #107 to fix crash bug. Added additional tests to ensure this kind of crash bug doesn't get through again.
  • Added back the now fixed fd_set extension. PR #111.
  • The connect(to:port:timeout:) API will now throw an exception if called on a non-blocking socket without the optional timeout being passed with a value greater than zero. Updated documentation to reflect this.
  • Changes to adapt to Swift 4.1. Encompasses PR #121 and other related changes.
  • Fixed a bit-addressing error in fd_set implementation. Make sure that the temporary socket opened in Socket.connect(to:port:timeout:) is closed in the event of an error being thrown. See PR #126 for more information. This fixes the following issues: #120, #123 and #125.
BlueSocket - Update to latest Xcode (Beta 6) and toolchain (8/15).

Published by billabt about 8 years ago

This release requires use of the swift-DEVELOPMENT-SNAPSHOT-2016-08-15-a toolchain.

  • Compatible with Xcode 8 Beta 6 using the above toolchain.
  • Added support for arm architecture for FD utilities.
  • Added nine (9) new tests to test suite including a full test server helper function that uses Dispatch.
  • IMPORTANT NOTE Testing requires a working Dispatch module in the toolchain. See the README.md for more information.
  • Added 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.
  • Added 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.
  • Merged in support for non-blocking writes to TCP sockets per PR#15 submitted against the legacy-0.7 branch. Also available at tag 0.7.6 for use with the 7/25 toolchain.
  • See README.md for more information about the new API.
  • NSData and NSMutable data will be deprecated in a future release.
  • Removed verifyConnection() function from SSLServiceDelegate protocol. Now handled internally by SSLService itself.
  • Minor change to initialize delegate function of SSLServiceDelegate. SSLService.inititalize(isServer:) became SSLService.initialize(asServer:).
  • Updated example in README.md to use multi-threaded Dispatch based API.
  • Added instructions for building and installing Dispatch into the 8/15 Linux toolchain.
BlueSocket - New APIs, new platform support, new test suite, new (8/7) toolchain.

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.

  • Added support for arm architecture for FD utilities.
  • Added nine (9) new tests to test suite including a full test server helper function that uses Dispatch.
  • IMPORTANT NOTE Testing requires a working Dispatch module in the toolchain. See the README.md for more information.
  • Added 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.
  • Added 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.
  • Merged in support for non-blocking writes to TCP sockets per PR#15 submitted against the legacy-0.7 branch. Also available at tag 0.7.6 for use with the 7/25 toolchain.
  • NSData and NSMutable data will be deprecated in a future release.
  • Removed verifyConnection() function from SSLServiceDelegate protocol. Now handled internally by SSLService itself.
  • See README.md for more information about the new API.
  • Works with Xcode 8 Beta 4 using the above toolchain.
  • Updated example in README.md to use multi-threaded Dispatch based API.
  • Added instructions for building and installing Dispatch into the 8/4 or 8/7 Linux toolchain.
BlueSocket - New APIs, new platform support, new test suite.

Published by billabt about 8 years ago

This release requires use of the new swift-DEVELOPMENT-SNAPSHOT-2016-07-25-a toolchain.

  • Added support for arm architecture for FD utilities.
  • Added beginnings of a test suite.
  • Added 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.
  • Added write(from data: Data) - This function writes the data contained within the Data object to the socket.
  • See README.md for more information about the new API.
  • Works with Xcode 8 Beta 4 Default Toolchain.
BlueSocket - Updates for the swift-DEVELOPMENT-SNAPSHOT-2016-06-20-a toolchain

Published by billabt over 8 years ago

This release requires use of the new swift-DEVELOPMENT-SNAPSHOT-2016-06-20-a toolchain.

  • Changes in response to Issue #6. Socket.wait() now supports a timed wait based on a passed timer value, an immediate return (i.e. quick check) and an indefinite wait.
  • Changed SOCKET_DEFAULT_MAX_CONNECTIONS to SOCKET_DEFAULT_MAX_BACKLOG and changed the default from 5 to 50.
  • Added SOCKET_MAX_DARWIN_BACKLOG for macOS.
  • Changed the signature of listen(on port: Int, maxPendingConnections: Int) to listen(on port: Int, maxBacklogSize: Int = Socket.SOCKET_DEFAULT_MAX_BACKLOG) and removed the listen(on port: Int) API since the same can be accomplished using defaults.
  • Updated documentation in README.md to reflect changes.
BlueSocket - Compatible with 5/09, 05/31 and 6/06 Binaries

Published by billabt over 8 years ago

  • Important: This release requires use of the 5/03, 5/31 or 6/06 DEVELOPMENT release of the toolchain.
  • Replaced make*() API's with create() (various forms depending on what you're creating). To create a socket using default parameters, use create().
  • Changed Error from class to struct.
  • Improved error handling when determining protocol family of newly connected or listening sockets.
  • Wrappered socket fd functions into FD class and changed names to look more familiar with their 'C' counterparts. i.e. FD_SET in C becomes FD.SET in Swift.
  • Check for interrupt during accept call and re-issue call if interrupted. This allows setting of breakpoints while listening for a connection.
  • Enums have been lowerCamelCased in accordance with Swift 3.0 API guidelines.
  • Added new wait() API to monitor an array of sockets, returning when data is available or timeout occurs.
  • Added hooks for using SSLService plugin (when available).
  • Added boolean value to the Signature to indicate whether the Socket instance is secure or not.
BlueSocket - Major Changes to Conform to Swift 3.0 API Guidelines

Published by billabt over 8 years ago

  • Important: This release requires use of the 3/16 DEVELOPMENT release of the toolchain.
  • While the project name, BlueSocket remains the same, the actual framework name is now just Socket. For importing in your programs, where you used to use:
import BlueSocket

you should now use:

 import Socket
  • In keeping with this, all references to BlueSocket have been changed to Socket including the reader and writer protocols.
  • Some of the public properties and a lot of the public functions within Socket and its structs/enums have been refactored and had their signatures changed. This was done in an effort to conform to Swift 3.0 API guidelines. The following table lists these changes:
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
BlueSocket - Bug fixes

Published by billabt over 8 years ago

Bug fixes:

  • Fixed a big bug on Linux. The use of sockaddr_storage for storage of both sockaddr_in and sockaddr_in6 structs does not work on Linux. It appears to be the way the struct is defined on Linux versus the way it's defined on OS X. The result was that the address and port number were being corrupted. This solves the problem by storing the addresses in an enum with associated values.
  • Replaced the inefficient toXXX() utility functions associated with sockaddr_storage, sockaddr_in and sockaddr_in6 with versions that do a simple cast rather than allocating new structures.
  • Fixed a problem with the port values. They were not be byte swapped when converting from network format.
BlueSocket - Usability Enhancements

Published by billabt over 8 years ago

Some major refactoring of the code internals that makes the API a bit more easier to use:

  • BlueSocket.BlueSocketSignature is now BlueSocket.Signature,
  • BlueSocketError has become BlueSocket.Error.
  • BlueSocket.BlueSocketProtocolFamily has become BlueSocket.ProtocolFamily.
  • BlueSocket.BlueSocketType has become BlueSocket.SocketType.
  • BlueSocket.BlueSocketProtocol has become BlueSocket.SocketProtocol.
  • Added domain property to BlueSocket.Error.

Additionally, added code to allow listening sockets to avoid dying from a SIGPIPE signal for an interrupted connection.

BlueSocket - Protocol Independence

Published by billabt over 8 years ago

What's changed in this release:

  • Updated to use the latest swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a drop of the Swift toolchain. Use of this drop or higher is REQUIRED.
  • Changed library to be protocol independent. It now fully supports both IPV4 and IPV6 including listening on an IPV6 socket.
  • Removed use of gethostbyname() since it's obsolete and replaced it with the more modern getaddrinfo().
  • Added extensions for sockaddr, sockaddr_in, sockaddr_in6 and sockaddr_storage to facilitate conversions based on the protocol family.
  • Improved documentation adding missing where needed.
  • Replaced the 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.
  • Added code to maintain signatures for all connected sockets. This can be accessed via the signature property.
  • Added new class function that allows creation of a connected socket using a BlueSocketSignature, BlueSocket.createConnected(Signature:). Accompanying that, added an instance function, connectUsing(Signature:), that allows connection to be achieved by providing a BlueSocketSignature object.
  • Added convenient method for creating a BlueSocketSignature to make it easier to use the new class function to create a connected socket all in one step.
  • Added new class function that allows creation of a BlueSocket instance using an existing raw socket fd and address.
BlueSocket - UDP Beginnings

Published by billabt over 8 years ago

Beginnings of support for UDP. Not yet available.

BlueSocket - Minor enhancements

Published by billabt over 8 years ago

Added new class function to check the readability/writability of an array of BlueSockets.

BlueSocket - Initial public release

Published by billabt over 8 years ago

Package Rankings
Top 15.37% on Carthage
Top 3.63% on Swiftpackageindex.com
Top 1.16% on Cocoapods.org