Releases: Kitura/BlueSocket
Releases · Kitura/BlueSocket
Compatible with 5/09, 05/31 and 6/06 Binaries
- Important: This release requires use of the
5/03, 5/31 or 6/06 DEVELOPMENT
release of the toolchain. - Replaced
make*()
API's withcreate()
(various forms depending on what you're creating). To create a socket using default parameters, usecreate()
. - Changed Error from
class
tostruct
. - 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 becomesFD.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.
Major Changes to Conform to Swift 3.0 API Guidelines
- 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 |
Bug fixes
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.
Usability Enhancements
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.
Protocol Independence
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 isREQUIRED
. - 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
andsockaddr_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 robustBlueSocket.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 aBlueSocketSignature
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.
UDP Beginnings
Beginnings of support for UDP. Not yet available.
Minor enhancements
Added new class function to check the readability/writability of an array of BlueSockets.
Initial public release
0.0.3 Merge branch 'master' of github.com:IBM-Swift/BlueSocket