218 Commits

Author SHA1 Message Date
Danny Sung 8e7dc0469a Fix swift argument parser (#215)
* Resolved dependency on SwiftArgumentParser

- Moved BlueSocketTestClient and BlueSocketTestServer to Examples folder
  with it's own Package.swift file

* Update minimum swift argument parser to 1.1.3

* Update podspec; Update travis build platforms.
2022-07-21 22:51:21 -07:00
Danny Sung 4dd6c81f28 travis: update CI environments (#202)
* travis: update CI environments
* Add BlueSocketTestCommonLibrary, BlueSocketTestClient, BlueSocketTestServer
- Add a library component to make it easier to do tests and profiling under streaming loads (multiple client connections, lots of data, etc.)

* Removed Swift 4.x, bumped minimum swift version requirement to 5.1
* keep build at Swift 5.0; update CI to only test from 5.1.5 on up
* Only attempt to build command-line for Swift 5.2+
* Ensure tools and dependencies only build for Swift 5.2+
* Address various lint errors
* Update README with version details and latest iOS related issues
2021-06-16 22:18:24 -07:00
David Jones 0830287874 Resolve compile warnings in future versions of Swift 2019-10-01 09:46:08 +01:00
Bill Abt 49cab699e9 Minor format changes and adding of additional comments. 2019-08-27 10:18:21 -04:00
Lei Zhang 0d37c602eb Fix the retrieve of the UNIX address as an UnsafeMutablePointer for big endian 2019-08-16 10:54:55 -07:00
David Jones 2973532ec9 Resolve Swift 5 compile warnings 2019-04-04 12:02:17 +01:00
Bill Abt 48a77e2e35 Documentation quality and consistency improvements. 2018-12-14 10:56:36 -05:00
Bill Abt b911b29416 When attempting to connect a socket that is already connected, the error code being returned was correct but the error message text that was being returned was the exact opposite of the actual error. 2018-12-14 09:53:41 -05:00
Bill Abt 9dc3e45be9 Minor code change to use the nil coalescing to improve readability. Improved internal documentation to call out specific notations supported. 2018-12-14 08:42:35 -05:00
Bill Abt 9d77d6b212 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. 2018-12-13 11:00:56 -05:00
David Jones cfe4868e27 Resolve Swift 5 compilation warnings 2018-11-27 16:53:58 +00:00
Bill Abt 0e30af1d7d Fixed buffer overflow problem that only showed up in optimized code. 2018-09-28 17:59:34 -04:00
Bill Abt 8dfecd3df6 Minor formatting changes. Added additional documentation. 2018-09-04 10:27:50 -04:00
Fred Cox cdfa5bc882 No need to use fallthrough in this switch 2018-08-30 15:07:41 +03:00
Fred Cox 114f6b98ea Set remoteConnectionClosed = true for all ECONNRESET 2018-08-30 15:04:47 +03:00
Fred Cox a4ffe7e027 Rearrange connect(using signature: Signature) to use address if its set before hostname
Also allow creating a Signature with Address and hostname

In this case the hostname is only used for SSL verification as the address is already resolved
2018-08-30 12:27:29 +03:00
Fred Cox dedea0de3a Allow creating signature from Address 2018-08-30 12:18:33 +03:00
Ian Partridge 103e4ec265 Update comment 2018-08-01 13:11:25 +01:00
Ian Partridge 6eec5f8d44 Initialize readBuffer with to: 2018-07-30 17:10:05 +01:00
Bouke Haarsma ede2b21dce Make connect() work for UDP sockets as well 2018-06-03 08:18:05 +02:00
Bill Abt 1c6757164f For consistency with the rest of the project, converted spaces to tabs. 2018-04-12 09:50:34 -04:00
Bill Abt 7f8a771a17 Merge pull request #131 from ShihabMehboob/issue.754
Added descriptive error reasons
2018-04-12 09:41:25 -04:00
Bill Abt eea0bcf594 Merge pull request #130 from tnakaike/endian-fix
Endian fix
2018-04-12 08:13:16 -04:00
Shihab-Mehboob1 d368504ecd Added descriptive error reasons 2018-04-12 10:36:13 +01:00
Takuya Nakaike 441e3d5cfa Removed parentheses 2018-04-10 19:23:20 +09:00
Takuya Nakaike 1606b1b059 Modified #if condition to _endian(big) 2018-04-10 11:51:55 +09:00
Bill Abt 8ce3961e63 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. 2018-04-09 10:21:39 -04:00
Bill Abt db43361274 When calling getaddrinfo(), the hints variable should reflect the protocol family of the socket. Thanks @lucJW. 2018-04-05 10:46:54 -04:00
Takuya Nakaike 2fea7f037f Inserted #if guard for s390x 2018-04-03 14:45:52 +09:00
Takuya Nakaike f2c9b5dd29 Fix for big-endian machines
fd_set is defined as 16 64-bit integers in a 64-bit linux machine. Since this package accesses fd_set per 32 bits, endianess needs to be taken aware to calculate the index.
2018-03-30 17:39:26 +09:00
Jim Dovey c8ee463a06 Makes sure that the temporary socket opened in Socket.connect(to:port:timeout:) is closed in the event of an error being thrown.
I've added two pieces here: first is a `defer` block right after the creation of the `socketDescriptor` variable. If it's non-nil and not `Socket.SOCKET_INVALID_DESCRIPTOR` then the socket is closed pronto. Secondly, I'm explicitly setting this variable to `nil` when it's copied into `self.socketfd`. From that point on, any failure or error thrown will not result in the socket being orphaned, since it's referenced by the `Socket` class instance, and will be cleaned up in its `deinit` implementation.
2018-02-22 13:08:31 -08:00
Jim Dovey 74bbadbc7a Fixed a bit-addressing error in fd_set implementation.
- Now uses an unsigned type to perform the bit-shift operation and then casts to signed type using `init(bitPattern:)`.
- Added a unit test case which ensures fd values from zero to (arbitrarily) 128 can all be inserted and removed from the fd_set.
2018-02-22 12:42:08 -08:00
Bill Abt f49d9dabdb Changed to use new SSLError initializer that was changed to accommodate changes in Swift 4.1. 2018-02-21 10:50:39 -05:00
Bill Abt 9979951ee3 Changed name of SSLError.code to SSLError.errCode to avoid clash with Swift.Error._code that was flagged as a warning in Swift 4.1. 2018-02-21 10:49:36 -05:00
Bill Abt 8f31fff919 Merge pull request #121 from IBM-Swift/issue.swift41
Update to support Swift 4.1
2018-02-21 10:19:22 -05:00
ShihabMehboob fd15ef5d44 Squashed commit of the following:
commit d658dc3618946a6d295f1604fb8a8378d8d3f1f6
Author: ShihabMehboob <shihab.mehboob1@ibm.com>
Date:   Wed Feb 14 13:18:31 2018 +0000

    Updates to Swift 4.1

commit fc48ea6a203914081a060424d79af89a96578c7b
Author: ShihabMehboob <shihab.mehboob1@ibm.com>
Date:   Wed Feb 14 13:14:17 2018 +0000

    Updates to Swift 4.1

commit 3f2c276c247aa4d97a52a65eae0804fa3028261b
Author: ShihabMehboob <shihab.mehboob1@ibm.com>
Date:   Wed Feb 14 13:13:56 2018 +0000

    Updates to Swift 4.1

commit 664e5ce38c679498a8f35a7adbc22beb70cd08b4
Author: ShihabMehboob <shihab.mehboob1@ibm.com>
Date:   Wed Feb 14 13:11:01 2018 +0000

    Updates to Swift 4.1

commit 985ea641cbbb1cc7d37a8aa1a19ca019221f0b81
Author: ShihabMehboob <shihab.mehboob1@ibm.com>
Date:   Wed Feb 14 12:52:38 2018 +0000

    Updates to Swift 4.1

commit 1f74bb681948aca741c3dec025f73aa341efef0f
Author: ShihabMehboob <shihab.mehboob1@ibm.com>
Date:   Mon Feb 12 10:27:00 2018 +0000

    Support Swift 4.1

commit c86c534b84fb0fcee04030ae948650ab3f5e78df
Author: ShihabMehboob <shihab.mehboob1@ibm.com>
Date:   Thu Feb 8 13:59:20 2018 +0000

    Support Swift 4.1
2018-02-14 13:20:55 +00:00
Bill Abt c8c1a1e9c1 Throw an exception if connect is called on a non-blocking socket without a timeout being passed. Updated documentation to reflect this. 2018-02-13 11:22:34 -05:00
Bill Abt 5c07437ab5 Added documentation for public functions. Minor format changes for consistency. 2018-01-27 08:57:26 -05:00
Jim Dovey fec7cf7438 Fixed the bug in the new fd_set implementation on macOS. 2018-01-26 16:49:44 -08:00
Bill Abt d3c5ff3ecd Rollback the fd_set extension changes from PR #107 to the original. The changes were causing a crash bug whenever the new fd_set extensions were called. 2018-01-22 10:32:30 -05:00
Bill Abt c2cdc36148 Renamed disableSIGPIPE function to ignoreSIGPIPE since that's just a bit more descriptive. Other minor style changes for consistency. 2018-01-19 09:22:22 -05:00
Bill Abt 45da6eb972 Minor style changes. 2018-01-19 09:21:06 -05:00
Jim Dovey 171c7570d7 A few cleanups and one bug fix:
- `fd_set` API is now much nicer and will compile about as close to the C implementation as we can get— especially on release builds, with compiler inlining.
- Socket structure's `readBuffer` now initializes all its bytes to zero, not just the first.
- More idiomatic/concise return expression in `Socket.wait(for:timeout:waitForever:)` (don't build an output array manually, we have `filter(_:)` for that).
- Various non-Linux code to set the `SO_NOSIGPIPE` option has been tucked into a private function now, still containing the compilation conditional. It's a no-op on Linux, and will be inlined by the compiler (since it's private) and the calling code looks much more straightforward.
- BUGFIX: calls to `gai_strerror(_:)` take the result of the `getaddrinfo()` call as a parameter, NOT `errno`.
2018-01-16 12:53:27 -08:00
Bill Abt f9a7368c84 Minor fix in datagram handling when a datagram read is interrupted. 2017-12-14 09:13:11 -05:00
Bill Abt dc44869fc4 Added missing documentation for allowPortReuse on the listen() API. Part of issue #94. 2017-10-26 17:57:38 -04:00
Bill Abt fb0c9c1e87 Introduced OperationInterrupted exception to replace NotAnError that was included in PR #93. This makes things clearer. Also, made the new exception part of Socket to avoid redundant declarations. 2017-10-26 10:03:19 -04:00
Bill Abt abfe351df1 Added missing documentation for new Socket.Address extensions introduced by PR #93. 2017-10-26 10:00:02 -04:00
Bill Abt eaddb730d8 Merge pull request #93 from mcfedr/fix-unsafe-socket
Remove unsafe access to Socket.Address.  Some modifications needed prior to release.
2017-10-26 09:24:27 -04:00
Bill Abt badbf15cb8 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. 2017-10-12 10:30:12 -04:00
Fred Cox 2d58a7a264 Remove unsafe access to Socket.Address
asAddr funcs were passing unsafe pointers outside of the callbacks in which try should be used
Using callback to make all the access within these callbacks
Fixes bug where IPv6 address was 'cast' to sockaddr but actually was zero'd beyond the length of sockaddr_in and packets written to the wrong address
2017-10-12 10:51:40 +03:00