├── .gitignore ├── .travis.yml ├── Demo ├── EchoServer │ ├── .gitignore │ ├── Package.swift │ └── Sources │ │ └── main.swift └── EchoServerCocoa │ ├── EchoServer.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata │ ├── EchoServer.xcworkspace │ └── contents.xcworkspacedata │ ├── EchoServer │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ └── Main.storyboard │ ├── Info.plist │ └── ViewController.swift │ ├── Podfile │ └── Podfile.lock ├── LICENSE ├── Package.swift ├── README.md ├── Sources └── SwiftDSSocket.swift ├── SwiftDSSocket.podspec ├── SwiftDSSocket.xcodeproj ├── SwiftDSSocketTests_Info.plist ├── SwiftDSSocket_Info.plist ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ ├── SwiftDSSocket.xcscheme │ └── xcschememanagement.plist ├── Tests └── SwiftDSSocketTests │ ├── CloseAfterReadWrite.swift │ ├── ConnectAndListen.swift │ ├── ConnectGoogleIPv6Only.swift │ ├── ConnectToWhenPortOff.swift │ ├── IPv4and6Connect.swift │ ├── KernelCommunication.swift │ ├── PartialReadAndWrite.swift │ ├── TransferSpeciedDataWithGivenBuffer.swift │ ├── TransferSpecifiedData.swift │ └── TransferUnspecifiedData.swift └── docs ├── Classes.html ├── Classes ├── SwiftDSSocket.html └── SwiftDSSocket │ ├── SocketError.html │ ├── SocketError │ └── ErrorKind.html │ └── SocketType.html ├── Protocols.html ├── Protocols └── SwiftDSSocketDelegate.html ├── badge.svg ├── css ├── highlight.css └── jazzy.css ├── docsets ├── SwiftDSSocket.docset │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ ├── Documents │ │ ├── Classes.html │ │ ├── Classes │ │ │ ├── SwiftDSSocket.html │ │ │ └── SwiftDSSocket │ │ │ │ ├── SocketError.html │ │ │ │ ├── SocketError │ │ │ │ └── ErrorKind.html │ │ │ │ └── SocketType.html │ │ ├── Protocols.html │ │ ├── Protocols │ │ │ └── SwiftDSSocketDelegate.html │ │ ├── badge.svg │ │ ├── css │ │ │ ├── highlight.css │ │ │ └── jazzy.css │ │ ├── img │ │ │ ├── carat.png │ │ │ ├── dash.png │ │ │ └── gh.png │ │ ├── index.html │ │ ├── js │ │ │ ├── jazzy.js │ │ │ └── jquery.min.js │ │ ├── search.json │ │ └── undocumented.json │ │ └── docSet.dsidx └── SwiftDSSocket.tgz ├── img ├── carat.png ├── dash.png └── gh.png ├── index.html ├── js ├── jazzy.js └── jquery.min.js ├── search.json └── undocumented.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | # OS trash 10 | .DS_Store 11 | 12 | ## Various settings 13 | *.pbxuser 14 | !default.pbxuser 15 | *.mode1v3 16 | !default.mode1v3 17 | *.mode2v3 18 | !default.mode2v3 19 | *.perspectivev3 20 | !default.perspectivev3 21 | xcuserdata/ 22 | 23 | ## Other 24 | *.moved-aside 25 | *.xccheckout 26 | *.xcscmblueprint 27 | 28 | ## Obj-C/Swift specific 29 | *.hmap 30 | *.ipa 31 | *.dSYM.zip 32 | *.dSYM 33 | 34 | ## Playgrounds 35 | timeline.xctimeline 36 | playground.xcworkspace 37 | 38 | # Swift Package Manager 39 | # 40 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 41 | Packages/ 42 | Package.pins 43 | .build/ 44 | 45 | # CocoaPods 46 | # 47 | # We recommend against adding the Pods directory to your .gitignore. However 48 | # you should judge for yourself, the pros and cons are mentioned at: 49 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 50 | # 51 | Pods/ 52 | 53 | # Carthage 54 | # 55 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 56 | Carthage/Checkouts 57 | 58 | Carthage/Build 59 | 60 | # fastlane 61 | # 62 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 63 | # screenshots whenever they are needed. 64 | # For more information about the recommended setup visit: 65 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 66 | 67 | fastlane/report.xml 68 | fastlane/Preview.html 69 | fastlane/screenshots 70 | fastlane/test_output 71 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | os: osx 3 | osx_image: xcode8.3 4 | 5 | script: 6 | - swift test 7 | -------------------------------------------------------------------------------- /Demo/EchoServer/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | -------------------------------------------------------------------------------- /Demo/EchoServer/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:3.1 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "EchoServer", 7 | dependencies: [ 8 | .Package(url: "https://github.com/csujedihy/SwiftDSSocket.git", "0.0.4") 9 | ] 10 | ) 11 | -------------------------------------------------------------------------------- /Demo/EchoServer/Sources/main.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import SwiftDSSocket 3 | 4 | class EchoServer: SwiftDSSocketDelegate { 5 | var server: SwiftDSSocket? 6 | var newClient: SwiftDSSocket? 7 | 8 | let ServerTag = 0 9 | 10 | func run() { 11 | server = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 12 | try? server?.accept(onPort: 9999) 13 | dispatchMain() 14 | } 15 | 16 | func socket(sock: SwiftDSSocket, didAcceptNewSocket newSocket: SwiftDSSocket) { 17 | newClient = newSocket 18 | newSocket.readData(tag: ServerTag) 19 | } 20 | 21 | func socket(sock: SwiftDSSocket, didRead data: Data, tag: Int) { 22 | sock.write(data: data, tag: ServerTag) 23 | sock.readData(tag: ServerTag) 24 | } 25 | } 26 | 27 | let server = EchoServer() 28 | server.run() -------------------------------------------------------------------------------- /Demo/EchoServerCocoa/EchoServer.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 73ACEFAAF21511BC6A920872 /* Pods_EchoServer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B03DEBDA1F2B00C861F2AD6E /* Pods_EchoServer.framework */; }; 11 | C13FD0031F300E1400C96F67 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C13FD0021F300E1400C96F67 /* AppDelegate.swift */; }; 12 | C13FD0051F300E1400C96F67 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C13FD0041F300E1400C96F67 /* ViewController.swift */; }; 13 | C13FD0071F300E1400C96F67 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C13FD0061F300E1400C96F67 /* Assets.xcassets */; }; 14 | C13FD00A1F300E1400C96F67 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C13FD0081F300E1400C96F67 /* Main.storyboard */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 9F222943427302BAD8CD9F3F /* Pods-EchoServer.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EchoServer.release.xcconfig"; path = "Pods/Target Support Files/Pods-EchoServer/Pods-EchoServer.release.xcconfig"; sourceTree = ""; }; 19 | B03DEBDA1F2B00C861F2AD6E /* Pods_EchoServer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_EchoServer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | C13FCFFF1F300E1400C96F67 /* EchoServer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = EchoServer.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | C13FD0021F300E1400C96F67 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | C13FD0041F300E1400C96F67 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 23 | C13FD0061F300E1400C96F67 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | C13FD0091F300E1400C96F67 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 25 | C13FD00B1F300E1400C96F67 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | CC090AA71449C6701963E5BC /* Pods-EchoServer.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EchoServer.debug.xcconfig"; path = "Pods/Target Support Files/Pods-EchoServer/Pods-EchoServer.debug.xcconfig"; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | C13FCFFC1F300E1400C96F67 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | 73ACEFAAF21511BC6A920872 /* Pods_EchoServer.framework in Frameworks */, 35 | ); 36 | runOnlyForDeploymentPostprocessing = 0; 37 | }; 38 | /* End PBXFrameworksBuildPhase section */ 39 | 40 | /* Begin PBXGroup section */ 41 | 74EC1A3754261CD26F3CD72A /* Pods */ = { 42 | isa = PBXGroup; 43 | children = ( 44 | CC090AA71449C6701963E5BC /* Pods-EchoServer.debug.xcconfig */, 45 | 9F222943427302BAD8CD9F3F /* Pods-EchoServer.release.xcconfig */, 46 | ); 47 | name = Pods; 48 | sourceTree = ""; 49 | }; 50 | 9BB2EEFDB553B15F00290997 /* Frameworks */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | B03DEBDA1F2B00C861F2AD6E /* Pods_EchoServer.framework */, 54 | ); 55 | name = Frameworks; 56 | sourceTree = ""; 57 | }; 58 | C13FCFF61F300E1400C96F67 = { 59 | isa = PBXGroup; 60 | children = ( 61 | C13FD0011F300E1400C96F67 /* EchoServer */, 62 | C13FD0001F300E1400C96F67 /* Products */, 63 | 74EC1A3754261CD26F3CD72A /* Pods */, 64 | 9BB2EEFDB553B15F00290997 /* Frameworks */, 65 | ); 66 | sourceTree = ""; 67 | }; 68 | C13FD0001F300E1400C96F67 /* Products */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | C13FCFFF1F300E1400C96F67 /* EchoServer.app */, 72 | ); 73 | name = Products; 74 | sourceTree = ""; 75 | }; 76 | C13FD0011F300E1400C96F67 /* EchoServer */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | C13FD0021F300E1400C96F67 /* AppDelegate.swift */, 80 | C13FD0041F300E1400C96F67 /* ViewController.swift */, 81 | C13FD0061F300E1400C96F67 /* Assets.xcassets */, 82 | C13FD0081F300E1400C96F67 /* Main.storyboard */, 83 | C13FD00B1F300E1400C96F67 /* Info.plist */, 84 | ); 85 | path = EchoServer; 86 | sourceTree = ""; 87 | }; 88 | /* End PBXGroup section */ 89 | 90 | /* Begin PBXNativeTarget section */ 91 | C13FCFFE1F300E1400C96F67 /* EchoServer */ = { 92 | isa = PBXNativeTarget; 93 | buildConfigurationList = C13FD00E1F300E1400C96F67 /* Build configuration list for PBXNativeTarget "EchoServer" */; 94 | buildPhases = ( 95 | A2EAA46E9C1C6FBDE106BDA4 /* [CP] Check Pods Manifest.lock */, 96 | C13FCFFB1F300E1400C96F67 /* Sources */, 97 | C13FCFFC1F300E1400C96F67 /* Frameworks */, 98 | C13FCFFD1F300E1400C96F67 /* Resources */, 99 | F7F107DCFFF2A65FD3EB2D9C /* [CP] Embed Pods Frameworks */, 100 | 2E0B98A4A856ACEDE9319F40 /* [CP] Copy Pods Resources */, 101 | ); 102 | buildRules = ( 103 | ); 104 | dependencies = ( 105 | ); 106 | name = EchoServer; 107 | productName = EchoServer; 108 | productReference = C13FCFFF1F300E1400C96F67 /* EchoServer.app */; 109 | productType = "com.apple.product-type.application"; 110 | }; 111 | /* End PBXNativeTarget section */ 112 | 113 | /* Begin PBXProject section */ 114 | C13FCFF71F300E1400C96F67 /* Project object */ = { 115 | isa = PBXProject; 116 | attributes = { 117 | LastSwiftUpdateCheck = 0830; 118 | LastUpgradeCheck = 0830; 119 | ORGANIZATIONNAME = "Yi Huang"; 120 | TargetAttributes = { 121 | C13FCFFE1F300E1400C96F67 = { 122 | CreatedOnToolsVersion = 8.3.3; 123 | ProvisioningStyle = Automatic; 124 | }; 125 | }; 126 | }; 127 | buildConfigurationList = C13FCFFA1F300E1400C96F67 /* Build configuration list for PBXProject "EchoServer" */; 128 | compatibilityVersion = "Xcode 3.2"; 129 | developmentRegion = English; 130 | hasScannedForEncodings = 0; 131 | knownRegions = ( 132 | en, 133 | Base, 134 | ); 135 | mainGroup = C13FCFF61F300E1400C96F67; 136 | productRefGroup = C13FD0001F300E1400C96F67 /* Products */; 137 | projectDirPath = ""; 138 | projectRoot = ""; 139 | targets = ( 140 | C13FCFFE1F300E1400C96F67 /* EchoServer */, 141 | ); 142 | }; 143 | /* End PBXProject section */ 144 | 145 | /* Begin PBXResourcesBuildPhase section */ 146 | C13FCFFD1F300E1400C96F67 /* Resources */ = { 147 | isa = PBXResourcesBuildPhase; 148 | buildActionMask = 2147483647; 149 | files = ( 150 | C13FD0071F300E1400C96F67 /* Assets.xcassets in Resources */, 151 | C13FD00A1F300E1400C96F67 /* Main.storyboard in Resources */, 152 | ); 153 | runOnlyForDeploymentPostprocessing = 0; 154 | }; 155 | /* End PBXResourcesBuildPhase section */ 156 | 157 | /* Begin PBXShellScriptBuildPhase section */ 158 | 2E0B98A4A856ACEDE9319F40 /* [CP] Copy Pods Resources */ = { 159 | isa = PBXShellScriptBuildPhase; 160 | buildActionMask = 2147483647; 161 | files = ( 162 | ); 163 | inputPaths = ( 164 | ); 165 | name = "[CP] Copy Pods Resources"; 166 | outputPaths = ( 167 | ); 168 | runOnlyForDeploymentPostprocessing = 0; 169 | shellPath = /bin/sh; 170 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-EchoServer/Pods-EchoServer-resources.sh\"\n"; 171 | showEnvVarsInLog = 0; 172 | }; 173 | A2EAA46E9C1C6FBDE106BDA4 /* [CP] Check Pods Manifest.lock */ = { 174 | isa = PBXShellScriptBuildPhase; 175 | buildActionMask = 2147483647; 176 | files = ( 177 | ); 178 | inputPaths = ( 179 | ); 180 | name = "[CP] Check Pods Manifest.lock"; 181 | outputPaths = ( 182 | ); 183 | runOnlyForDeploymentPostprocessing = 0; 184 | shellPath = /bin/sh; 185 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; 186 | showEnvVarsInLog = 0; 187 | }; 188 | F7F107DCFFF2A65FD3EB2D9C /* [CP] Embed Pods Frameworks */ = { 189 | isa = PBXShellScriptBuildPhase; 190 | buildActionMask = 2147483647; 191 | files = ( 192 | ); 193 | inputPaths = ( 194 | ); 195 | name = "[CP] Embed Pods Frameworks"; 196 | outputPaths = ( 197 | ); 198 | runOnlyForDeploymentPostprocessing = 0; 199 | shellPath = /bin/sh; 200 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-EchoServer/Pods-EchoServer-frameworks.sh\"\n"; 201 | showEnvVarsInLog = 0; 202 | }; 203 | /* End PBXShellScriptBuildPhase section */ 204 | 205 | /* Begin PBXSourcesBuildPhase section */ 206 | C13FCFFB1F300E1400C96F67 /* Sources */ = { 207 | isa = PBXSourcesBuildPhase; 208 | buildActionMask = 2147483647; 209 | files = ( 210 | C13FD0051F300E1400C96F67 /* ViewController.swift in Sources */, 211 | C13FD0031F300E1400C96F67 /* AppDelegate.swift in Sources */, 212 | ); 213 | runOnlyForDeploymentPostprocessing = 0; 214 | }; 215 | /* End PBXSourcesBuildPhase section */ 216 | 217 | /* Begin PBXVariantGroup section */ 218 | C13FD0081F300E1400C96F67 /* Main.storyboard */ = { 219 | isa = PBXVariantGroup; 220 | children = ( 221 | C13FD0091F300E1400C96F67 /* Base */, 222 | ); 223 | name = Main.storyboard; 224 | sourceTree = ""; 225 | }; 226 | /* End PBXVariantGroup section */ 227 | 228 | /* Begin XCBuildConfiguration section */ 229 | C13FD00C1F300E1400C96F67 /* Debug */ = { 230 | isa = XCBuildConfiguration; 231 | buildSettings = { 232 | ALWAYS_SEARCH_USER_PATHS = NO; 233 | CLANG_ANALYZER_NONNULL = YES; 234 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 235 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 236 | CLANG_CXX_LIBRARY = "libc++"; 237 | CLANG_ENABLE_MODULES = YES; 238 | CLANG_ENABLE_OBJC_ARC = YES; 239 | CLANG_WARN_BOOL_CONVERSION = YES; 240 | CLANG_WARN_CONSTANT_CONVERSION = YES; 241 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 242 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 243 | CLANG_WARN_EMPTY_BODY = YES; 244 | CLANG_WARN_ENUM_CONVERSION = YES; 245 | CLANG_WARN_INFINITE_RECURSION = YES; 246 | CLANG_WARN_INT_CONVERSION = YES; 247 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 248 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 249 | CLANG_WARN_UNREACHABLE_CODE = YES; 250 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 251 | CODE_SIGN_IDENTITY = "-"; 252 | COPY_PHASE_STRIP = NO; 253 | DEBUG_INFORMATION_FORMAT = dwarf; 254 | ENABLE_STRICT_OBJC_MSGSEND = YES; 255 | ENABLE_TESTABILITY = YES; 256 | GCC_C_LANGUAGE_STANDARD = gnu99; 257 | GCC_DYNAMIC_NO_PIC = NO; 258 | GCC_NO_COMMON_BLOCKS = YES; 259 | GCC_OPTIMIZATION_LEVEL = 0; 260 | GCC_PREPROCESSOR_DEFINITIONS = ( 261 | "DEBUG=1", 262 | "$(inherited)", 263 | ); 264 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 265 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 266 | GCC_WARN_UNDECLARED_SELECTOR = YES; 267 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 268 | GCC_WARN_UNUSED_FUNCTION = YES; 269 | GCC_WARN_UNUSED_VARIABLE = YES; 270 | MACOSX_DEPLOYMENT_TARGET = 10.12; 271 | MTL_ENABLE_DEBUG_INFO = YES; 272 | ONLY_ACTIVE_ARCH = YES; 273 | SDKROOT = macosx; 274 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 275 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 276 | }; 277 | name = Debug; 278 | }; 279 | C13FD00D1F300E1400C96F67 /* Release */ = { 280 | isa = XCBuildConfiguration; 281 | buildSettings = { 282 | ALWAYS_SEARCH_USER_PATHS = NO; 283 | CLANG_ANALYZER_NONNULL = YES; 284 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 285 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 286 | CLANG_CXX_LIBRARY = "libc++"; 287 | CLANG_ENABLE_MODULES = YES; 288 | CLANG_ENABLE_OBJC_ARC = YES; 289 | CLANG_WARN_BOOL_CONVERSION = YES; 290 | CLANG_WARN_CONSTANT_CONVERSION = YES; 291 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 292 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 293 | CLANG_WARN_EMPTY_BODY = YES; 294 | CLANG_WARN_ENUM_CONVERSION = YES; 295 | CLANG_WARN_INFINITE_RECURSION = YES; 296 | CLANG_WARN_INT_CONVERSION = YES; 297 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 298 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 299 | CLANG_WARN_UNREACHABLE_CODE = YES; 300 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 301 | CODE_SIGN_IDENTITY = "-"; 302 | COPY_PHASE_STRIP = NO; 303 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 304 | ENABLE_NS_ASSERTIONS = NO; 305 | ENABLE_STRICT_OBJC_MSGSEND = YES; 306 | GCC_C_LANGUAGE_STANDARD = gnu99; 307 | GCC_NO_COMMON_BLOCKS = YES; 308 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 309 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 310 | GCC_WARN_UNDECLARED_SELECTOR = YES; 311 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 312 | GCC_WARN_UNUSED_FUNCTION = YES; 313 | GCC_WARN_UNUSED_VARIABLE = YES; 314 | MACOSX_DEPLOYMENT_TARGET = 10.12; 315 | MTL_ENABLE_DEBUG_INFO = NO; 316 | SDKROOT = macosx; 317 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 318 | }; 319 | name = Release; 320 | }; 321 | C13FD00F1F300E1400C96F67 /* Debug */ = { 322 | isa = XCBuildConfiguration; 323 | baseConfigurationReference = CC090AA71449C6701963E5BC /* Pods-EchoServer.debug.xcconfig */; 324 | buildSettings = { 325 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 326 | COMBINE_HIDPI_IMAGES = YES; 327 | INFOPLIST_FILE = EchoServer/Info.plist; 328 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 329 | PRODUCT_BUNDLE_IDENTIFIER = io.proximac.swiftdssocket.EchoServer; 330 | PRODUCT_NAME = "$(TARGET_NAME)"; 331 | SWIFT_VERSION = 3.0; 332 | }; 333 | name = Debug; 334 | }; 335 | C13FD0101F300E1400C96F67 /* Release */ = { 336 | isa = XCBuildConfiguration; 337 | baseConfigurationReference = 9F222943427302BAD8CD9F3F /* Pods-EchoServer.release.xcconfig */; 338 | buildSettings = { 339 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 340 | COMBINE_HIDPI_IMAGES = YES; 341 | INFOPLIST_FILE = EchoServer/Info.plist; 342 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 343 | PRODUCT_BUNDLE_IDENTIFIER = io.proximac.swiftdssocket.EchoServer; 344 | PRODUCT_NAME = "$(TARGET_NAME)"; 345 | SWIFT_VERSION = 3.0; 346 | }; 347 | name = Release; 348 | }; 349 | /* End XCBuildConfiguration section */ 350 | 351 | /* Begin XCConfigurationList section */ 352 | C13FCFFA1F300E1400C96F67 /* Build configuration list for PBXProject "EchoServer" */ = { 353 | isa = XCConfigurationList; 354 | buildConfigurations = ( 355 | C13FD00C1F300E1400C96F67 /* Debug */, 356 | C13FD00D1F300E1400C96F67 /* Release */, 357 | ); 358 | defaultConfigurationIsVisible = 0; 359 | defaultConfigurationName = Release; 360 | }; 361 | C13FD00E1F300E1400C96F67 /* Build configuration list for PBXNativeTarget "EchoServer" */ = { 362 | isa = XCConfigurationList; 363 | buildConfigurations = ( 364 | C13FD00F1F300E1400C96F67 /* Debug */, 365 | C13FD0101F300E1400C96F67 /* Release */, 366 | ); 367 | defaultConfigurationIsVisible = 0; 368 | }; 369 | /* End XCConfigurationList section */ 370 | }; 371 | rootObject = C13FCFF71F300E1400C96F67 /* Project object */; 372 | } 373 | -------------------------------------------------------------------------------- /Demo/EchoServerCocoa/EchoServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Demo/EchoServerCocoa/EchoServer.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Demo/EchoServerCocoa/EchoServer/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // EchoServer 4 | // 5 | // Created by Yi Huang on 7/31/17. 6 | // Copyright © 2017 Yi Huang. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | 15 | 16 | func applicationDidFinishLaunching(_ aNotification: Notification) { 17 | // Insert code here to initialize your application 18 | } 19 | 20 | func applicationWillTerminate(_ aNotification: Notification) { 21 | // Insert code here to tear down your application 22 | } 23 | 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /Demo/EchoServerCocoa/EchoServer/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /Demo/EchoServerCocoa/EchoServer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2017 Yi Huang. All rights reserved. 27 | NSMainStoryboardFile 28 | Main 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /Demo/EchoServerCocoa/EchoServer/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // EchoServer 4 | // 5 | // Created by Yi Huang on 7/7/17. 6 | // Copyright © 2017 Yi Huang. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import SwiftDSSocket 11 | 12 | class ViewController: NSViewController { 13 | var newClient: SwiftDSSocket? 14 | var server: SwiftDSSocket? 15 | 16 | let ServerTag = 0 17 | let ClientTag = 1 18 | 19 | 20 | override func viewDidLoad() { 21 | super.viewDidLoad() 22 | server = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 23 | try? server?.accept(onPort: 9999) 24 | } 25 | 26 | } 27 | 28 | 29 | extension ViewController: SwiftDSSocketDelegate { 30 | func socket(sock: SwiftDSSocket, didAcceptNewSocket newSocket: SwiftDSSocket) { 31 | newClient = newSocket 32 | newSocket.readData(tag: ServerTag) 33 | } 34 | 35 | func socket(sock: SwiftDSSocket, didRead data: Data, tag: Int) { 36 | sock.write(data: data, tag: ServerTag) 37 | sock.readData(tag: ServerTag) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Demo/EchoServerCocoa/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target 'EchoServer' do 5 | # Comment the next line if you're not using Swift and don't want to use dynamic frameworks 6 | use_frameworks! 7 | pod 'SwiftDSSocket' 8 | # Pods for EchoServer 9 | 10 | end 11 | -------------------------------------------------------------------------------- /Demo/EchoServerCocoa/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SwiftDSSocket (0.0.2) 3 | 4 | DEPENDENCIES: 5 | - SwiftDSSocket 6 | 7 | SPEC CHECKSUMS: 8 | SwiftDSSocket: e025a38f27de74c532602d2991f8ac0cba084302 9 | 10 | PODFILE CHECKSUM: a7acd8240ed4ced4c3df3d1a73f1024074cf6e07 11 | 12 | COCOAPODS: 1.1.1 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Jedihy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:3.1 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "SwiftDSSocket" 7 | ) 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Travis-CI](https://api.travis-ci.org/csujedihy/SwiftDSSocket.svg?branch=master)](https://travis-ci.org/csujedihy/SwiftDSSocket) 2 | ![macOS](https://img.shields.io/badge/macOS-10.10%2B-green.svg?style=flat) 3 | ![iOS](https://img.shields.io/badge/iOS-9.0%2B-green.svg?style=flat) 4 | ![Swift Version](https://img.shields.io/badge/Swift-3.1-orange.svg?style=flat) 5 | [![CocoaPods](https://img.shields.io/cocoapods/v/SwiftDSSocket.svg?style=flat)](http://cocoadocs.org/docsets/SwiftDSSocket) 6 | [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 7 | ![SwiftPM Compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg) 8 | 9 | # SwiftDSSocket 10 | 11 | ## Overview 12 | 13 | SwiftDSSocket is a purely swift based **asynchronous** socket framework built atop DispatchSource. Function signatures are pretty much similar to those in CocoaAsyncSocket because I implemented this framework by learning the source code of CocoaAsyncSocket. The initial idea to build this framework is driven by the need of network library to communicate with KEXT (NKE) to re-write my [Proximac](https://github.com/csujedihy/proximac) project but none of frameworks I found in github supports that. Thus, I decided to implemented my own framework to do so. 14 | 15 | **Note:** This framework is still under active development. It only passes my unit tests and might have various bugs. 16 | 17 | ## Features 18 | ### Full Delegate Support 19 | 20 | * every operation invokes a call to your delagate method. 21 | 22 | ### IPv6 Support 23 | 24 | * listens only on IPv6 protocol but **accepts both** IPv4 and IPv6 incoming connections. 25 | * conforms to Apple's new App Store restriction on IPv6 only environment with NAT64/DNS64. 26 | 27 | ### DNS Enabled 28 | 29 | * takes advantage of sythesized IPv6 address introduced in `iOS 9` and `OS X 10.11` for better IPv6 support. 30 | * uses GCD to do DNS concurrently and connect to the first reachable address. 31 | 32 | 33 | ### KEXT Bi-directional Interaction 34 | 35 | * takes a bundle ID to interact with your KEXT like TCP stream. 36 | 37 | ## Using SwiftDSSocket 38 | 39 | ### Including in your project 40 | 41 | #### Swift Package Manager 42 | 43 | To include SwiftDSSocket into a Swift Package Manager package, add it to the `dependencies` attribute defined in your `Package.swift` file. For example: 44 | 45 | ``` 46 | dependencies: [ 47 | .Package(url: "https://github.com/csujedihy/SwiftDSSocket", "x.x.x") 48 | ] 49 | ``` 50 | 51 | #### CocoaPods 52 | To include SwiftDSSocket in a project using CocoaPods, you just add `SwiftDSSocket` to your `Podfile`, for example: 53 | 54 | ``` 55 | target 'MyApp' do 56 | use_frameworks! 57 | pod 'SwiftDSSocket' 58 | end 59 | ``` 60 | 61 | #### Carthage 62 | To include SwiftDSSocket in a project using Carthage, add a line to your `Cartfile` with the GitHub organization and project names and version. For example: 63 | 64 | ``` 65 | github "csujedihy/SwiftDSSocket" 66 | ``` 67 | 68 | ### Documentation 69 | [https://csujedihy.github.io/SwiftDSSocket/](https://csujedihy.github.io/SwiftDSSocket/) 70 | 71 | ### Example: 72 | 73 | The following example creates a default `SwiftDSSocket` instance and then *immediately* starts listening on port `9999` and echoes back everything sent to this server. 74 | 75 | You can simply use `telnet 127.0.0.1 9999` to connect to this server and send whatever you want. 76 | 77 | ```swift 78 | import Cocoa 79 | import SwiftDSSocket 80 | 81 | class ViewController: NSViewController { 82 | var server: SwiftDSSocket? 83 | var newClient: SwiftDSSocket? 84 | let ServerTag = 0 85 | 86 | override func viewDidLoad() { 87 | super.viewDidLoad() 88 | server = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 89 | try? server?.accept(onPort: 9999) 90 | } 91 | } 92 | 93 | 94 | extension ViewController: SwiftDSSocketDelegate { 95 | func socket(sock: SwiftDSSocket, didAcceptNewSocket newSocket: SwiftDSSocket) { 96 | newClient = newSocket 97 | newSocket.readData(tag: ServerTag) 98 | } 99 | 100 | func socket(sock: SwiftDSSocket, didRead data: Data, tag: Int) { 101 | sock.write(data: data, tag: ServerTag) 102 | sock.readData(tag: ServerTag) 103 | } 104 | } 105 | 106 | ``` 107 | 108 | **Tips:** Check out `Demo` folder to see more examples for different environments. 109 | -------------------------------------------------------------------------------- /SwiftDSSocket.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "SwiftDSSocket" 3 | s.version = "0.1.2" 4 | s.summary = "DispatchSource based sockets framework written in pure Swift 3.1" 5 | s.homepage = "https://github.com/csujedihy/SwiftDSSocket" 6 | s.license = "MIT" 7 | s.author = { "jedihy" => "csujedi@gmail.com" } 8 | s.social_media_url = "https://github.com/csujedihy" 9 | s.ios.deployment_target = "9.0" 10 | s.osx.deployment_target = "10.10" 11 | s.source = { :git => "https://github.com/csujedihy/SwiftDSSocket.git", :tag => "#{s.version}" } 12 | s.source_files = "Sources/**/*.swift" 13 | s.requires_arc = true 14 | s.xcconfig = { 'SWIFT_VERSION' => '3.1' } 15 | end 16 | -------------------------------------------------------------------------------- /SwiftDSSocket.xcodeproj/SwiftDSSocketTests_Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CFBundleDevelopmentRegion 5 | en 6 | CFBundleExecutable 7 | $(EXECUTABLE_NAME) 8 | CFBundleIdentifier 9 | $(PRODUCT_BUNDLE_IDENTIFIER) 10 | CFBundleInfoDictionaryVersion 11 | 6.0 12 | CFBundleName 13 | $(PRODUCT_NAME) 14 | CFBundlePackageType 15 | BNDL 16 | CFBundleShortVersionString 17 | 1.0 18 | CFBundleSignature 19 | ???? 20 | CFBundleVersion 21 | $(CURRENT_PROJECT_VERSION) 22 | NSPrincipalClass 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SwiftDSSocket.xcodeproj/SwiftDSSocket_Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.0.4 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /SwiftDSSocket.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C12EDDCB1F37C1300020EF7B /* IPv4and6Connect.swift in Sources */ = {isa = PBXBuildFile; fileRef = C12EDDCA1F37C1300020EF7B /* IPv4and6Connect.swift */; }; 11 | C12EDDCD1F37DAD30020EF7B /* ConnectGoogleIPv6Only.swift in Sources */ = {isa = PBXBuildFile; fileRef = C12EDDCC1F37DAD30020EF7B /* ConnectGoogleIPv6Only.swift */; }; 12 | C19DA7111F32F8FF009A9581 /* PartialReadAndWrite.swift in Sources */ = {isa = PBXBuildFile; fileRef = C19DA7101F32F8FF009A9581 /* PartialReadAndWrite.swift */; }; 13 | C19DA7171F35AD7D009A9581 /* TransferSpeciedDataWithGivenBuffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C19DA7161F35AD7D009A9581 /* TransferSpeciedDataWithGivenBuffer.swift */; }; 14 | C19DA71B1F366FCD009A9581 /* ConnectToWhenPortOff.swift in Sources */ = {isa = PBXBuildFile; fileRef = C19DA71A1F366FCD009A9581 /* ConnectToWhenPortOff.swift */; }; 15 | OBJ_27 /* SwiftDSSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_8 /* SwiftDSSocket.swift */; }; 16 | OBJ_34 /* CloseAfterReadWrite.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_11 /* CloseAfterReadWrite.swift */; }; 17 | OBJ_35 /* ConnectAndListen.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_12 /* ConnectAndListen.swift */; }; 18 | OBJ_36 /* KernelCommunication.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_13 /* KernelCommunication.swift */; }; 19 | OBJ_37 /* TransferSpecifiedData.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_14 /* TransferSpecifiedData.swift */; }; 20 | OBJ_38 /* TransferUnspecifiedData.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_15 /* TransferUnspecifiedData.swift */; }; 21 | OBJ_40 /* SwiftDSSocket.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = OBJ_20 /* SwiftDSSocket.framework */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXContainerItemProxy section */ 25 | C1A7A04A1F31975700D365F3 /* PBXContainerItemProxy */ = { 26 | isa = PBXContainerItemProxy; 27 | containerPortal = OBJ_1 /* Project object */; 28 | proxyType = 1; 29 | remoteGlobalIDString = OBJ_22; 30 | remoteInfo = SwiftDSSocket; 31 | }; 32 | /* End PBXContainerItemProxy section */ 33 | 34 | /* Begin PBXFileReference section */ 35 | C12EDDCA1F37C1300020EF7B /* IPv4and6Connect.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IPv4and6Connect.swift; sourceTree = ""; }; 36 | C12EDDCC1F37DAD30020EF7B /* ConnectGoogleIPv6Only.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConnectGoogleIPv6Only.swift; sourceTree = ""; }; 37 | C19DA7101F32F8FF009A9581 /* PartialReadAndWrite.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartialReadAndWrite.swift; sourceTree = ""; }; 38 | C19DA7121F331802009A9581 /* SwiftDSSocket.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SwiftDSSocket.podspec; sourceTree = ""; }; 39 | C19DA7131F331C31009A9581 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 40 | C19DA7161F35AD7D009A9581 /* TransferSpeciedDataWithGivenBuffer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransferSpeciedDataWithGivenBuffer.swift; sourceTree = ""; }; 41 | C19DA71A1F366FCD009A9581 /* ConnectToWhenPortOff.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConnectToWhenPortOff.swift; sourceTree = ""; }; 42 | OBJ_11 /* CloseAfterReadWrite.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloseAfterReadWrite.swift; sourceTree = ""; }; 43 | OBJ_12 /* ConnectAndListen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectAndListen.swift; sourceTree = ""; }; 44 | OBJ_13 /* KernelCommunication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KernelCommunication.swift; sourceTree = ""; }; 45 | OBJ_14 /* TransferSpecifiedData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransferSpecifiedData.swift; sourceTree = ""; }; 46 | OBJ_15 /* TransferUnspecifiedData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransferUnspecifiedData.swift; sourceTree = ""; }; 47 | OBJ_20 /* SwiftDSSocket.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = SwiftDSSocket.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | OBJ_21 /* SwiftDSSocketTests.xctest */ = {isa = PBXFileReference; lastKnownFileType = file; path = SwiftDSSocketTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | OBJ_6 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; 50 | OBJ_8 /* SwiftDSSocket.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDSSocket.swift; sourceTree = ""; }; 51 | /* End PBXFileReference section */ 52 | 53 | /* Begin PBXFrameworksBuildPhase section */ 54 | OBJ_28 /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 0; 57 | files = ( 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | OBJ_39 /* Frameworks */ = { 62 | isa = PBXFrameworksBuildPhase; 63 | buildActionMask = 0; 64 | files = ( 65 | OBJ_40 /* SwiftDSSocket.framework in Frameworks */, 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | /* End PBXFrameworksBuildPhase section */ 70 | 71 | /* Begin PBXGroup section */ 72 | OBJ_10 /* SwiftDSSocketTests */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | OBJ_12 /* ConnectAndListen.swift */, 76 | C19DA71A1F366FCD009A9581 /* ConnectToWhenPortOff.swift */, 77 | OBJ_13 /* KernelCommunication.swift */, 78 | OBJ_14 /* TransferSpecifiedData.swift */, 79 | OBJ_15 /* TransferUnspecifiedData.swift */, 80 | C19DA7101F32F8FF009A9581 /* PartialReadAndWrite.swift */, 81 | C19DA7161F35AD7D009A9581 /* TransferSpeciedDataWithGivenBuffer.swift */, 82 | OBJ_11 /* CloseAfterReadWrite.swift */, 83 | C12EDDCA1F37C1300020EF7B /* IPv4and6Connect.swift */, 84 | C12EDDCC1F37DAD30020EF7B /* ConnectGoogleIPv6Only.swift */, 85 | ); 86 | name = SwiftDSSocketTests; 87 | path = Tests/SwiftDSSocketTests; 88 | sourceTree = SOURCE_ROOT; 89 | }; 90 | OBJ_19 /* Products */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | OBJ_20 /* SwiftDSSocket.framework */, 94 | OBJ_21 /* SwiftDSSocketTests.xctest */, 95 | ); 96 | name = Products; 97 | sourceTree = BUILT_PRODUCTS_DIR; 98 | }; 99 | OBJ_5 = { 100 | isa = PBXGroup; 101 | children = ( 102 | C19DA7131F331C31009A9581 /* README.md */, 103 | C19DA7121F331802009A9581 /* SwiftDSSocket.podspec */, 104 | OBJ_6 /* Package.swift */, 105 | OBJ_7 /* Sources */, 106 | OBJ_9 /* Tests */, 107 | OBJ_19 /* Products */, 108 | ); 109 | sourceTree = ""; 110 | }; 111 | OBJ_7 /* Sources */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | OBJ_8 /* SwiftDSSocket.swift */, 115 | ); 116 | path = Sources; 117 | sourceTree = SOURCE_ROOT; 118 | }; 119 | OBJ_9 /* Tests */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | OBJ_10 /* SwiftDSSocketTests */, 123 | ); 124 | name = Tests; 125 | sourceTree = SOURCE_ROOT; 126 | }; 127 | /* End PBXGroup section */ 128 | 129 | /* Begin PBXNativeTarget section */ 130 | OBJ_22 /* SwiftDSSocket */ = { 131 | isa = PBXNativeTarget; 132 | buildConfigurationList = OBJ_23 /* Build configuration list for PBXNativeTarget "SwiftDSSocket" */; 133 | buildPhases = ( 134 | OBJ_26 /* Sources */, 135 | OBJ_28 /* Frameworks */, 136 | ); 137 | buildRules = ( 138 | ); 139 | dependencies = ( 140 | ); 141 | name = SwiftDSSocket; 142 | productName = SwiftDSSocket; 143 | productReference = OBJ_20 /* SwiftDSSocket.framework */; 144 | productType = "com.apple.product-type.framework"; 145 | }; 146 | OBJ_29 /* SwiftDSSocketTests */ = { 147 | isa = PBXNativeTarget; 148 | buildConfigurationList = OBJ_30 /* Build configuration list for PBXNativeTarget "SwiftDSSocketTests" */; 149 | buildPhases = ( 150 | OBJ_33 /* Sources */, 151 | OBJ_39 /* Frameworks */, 152 | ); 153 | buildRules = ( 154 | ); 155 | dependencies = ( 156 | OBJ_41 /* PBXTargetDependency */, 157 | ); 158 | name = SwiftDSSocketTests; 159 | productName = SwiftDSSocketTests; 160 | productReference = OBJ_21 /* SwiftDSSocketTests.xctest */; 161 | productType = "com.apple.product-type.bundle.unit-test"; 162 | }; 163 | /* End PBXNativeTarget section */ 164 | 165 | /* Begin PBXProject section */ 166 | OBJ_1 /* Project object */ = { 167 | isa = PBXProject; 168 | attributes = { 169 | LastUpgradeCheck = 9999; 170 | }; 171 | buildConfigurationList = OBJ_2 /* Build configuration list for PBXProject "SwiftDSSocket" */; 172 | compatibilityVersion = "Xcode 3.2"; 173 | developmentRegion = English; 174 | hasScannedForEncodings = 0; 175 | knownRegions = ( 176 | en, 177 | ); 178 | mainGroup = OBJ_5; 179 | productRefGroup = OBJ_19 /* Products */; 180 | projectDirPath = ""; 181 | projectRoot = ""; 182 | targets = ( 183 | OBJ_22 /* SwiftDSSocket */, 184 | OBJ_29 /* SwiftDSSocketTests */, 185 | ); 186 | }; 187 | /* End PBXProject section */ 188 | 189 | /* Begin PBXSourcesBuildPhase section */ 190 | OBJ_26 /* Sources */ = { 191 | isa = PBXSourcesBuildPhase; 192 | buildActionMask = 0; 193 | files = ( 194 | OBJ_27 /* SwiftDSSocket.swift in Sources */, 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | }; 198 | OBJ_33 /* Sources */ = { 199 | isa = PBXSourcesBuildPhase; 200 | buildActionMask = 0; 201 | files = ( 202 | C19DA7171F35AD7D009A9581 /* TransferSpeciedDataWithGivenBuffer.swift in Sources */, 203 | OBJ_34 /* CloseAfterReadWrite.swift in Sources */, 204 | OBJ_35 /* ConnectAndListen.swift in Sources */, 205 | OBJ_36 /* KernelCommunication.swift in Sources */, 206 | C12EDDCD1F37DAD30020EF7B /* ConnectGoogleIPv6Only.swift in Sources */, 207 | C12EDDCB1F37C1300020EF7B /* IPv4and6Connect.swift in Sources */, 208 | C19DA71B1F366FCD009A9581 /* ConnectToWhenPortOff.swift in Sources */, 209 | C19DA7111F32F8FF009A9581 /* PartialReadAndWrite.swift in Sources */, 210 | OBJ_37 /* TransferSpecifiedData.swift in Sources */, 211 | OBJ_38 /* TransferUnspecifiedData.swift in Sources */, 212 | ); 213 | runOnlyForDeploymentPostprocessing = 0; 214 | }; 215 | /* End PBXSourcesBuildPhase section */ 216 | 217 | /* Begin PBXTargetDependency section */ 218 | OBJ_41 /* PBXTargetDependency */ = { 219 | isa = PBXTargetDependency; 220 | target = OBJ_22 /* SwiftDSSocket */; 221 | targetProxy = C1A7A04A1F31975700D365F3 /* PBXContainerItemProxy */; 222 | }; 223 | /* End PBXTargetDependency section */ 224 | 225 | /* Begin XCBuildConfiguration section */ 226 | OBJ_24 /* Debug */ = { 227 | isa = XCBuildConfiguration; 228 | buildSettings = { 229 | ENABLE_TESTABILITY = YES; 230 | FRAMEWORK_SEARCH_PATHS = ( 231 | "$(inherited)", 232 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 233 | ); 234 | HEADER_SEARCH_PATHS = "$(inherited)"; 235 | INFOPLIST_FILE = SwiftDSSocket.xcodeproj/SwiftDSSocket_Info.plist; 236 | LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; 237 | OTHER_LDFLAGS = "$(inherited)"; 238 | OTHER_SWIFT_FLAGS = "$(inherited)"; 239 | PRODUCT_BUNDLE_IDENTIFIER = SwiftDSSocket; 240 | PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; 241 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 242 | SKIP_INSTALL = YES; 243 | TARGET_NAME = SwiftDSSocket; 244 | }; 245 | name = Debug; 246 | }; 247 | OBJ_25 /* Release */ = { 248 | isa = XCBuildConfiguration; 249 | buildSettings = { 250 | ENABLE_TESTABILITY = YES; 251 | FRAMEWORK_SEARCH_PATHS = ( 252 | "$(inherited)", 253 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 254 | ); 255 | HEADER_SEARCH_PATHS = "$(inherited)"; 256 | INFOPLIST_FILE = SwiftDSSocket.xcodeproj/SwiftDSSocket_Info.plist; 257 | LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; 258 | OTHER_LDFLAGS = "$(inherited)"; 259 | OTHER_SWIFT_FLAGS = "$(inherited)"; 260 | PRODUCT_BUNDLE_IDENTIFIER = SwiftDSSocket; 261 | PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; 262 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 263 | SKIP_INSTALL = YES; 264 | TARGET_NAME = SwiftDSSocket; 265 | }; 266 | name = Release; 267 | }; 268 | OBJ_3 /* Debug */ = { 269 | isa = XCBuildConfiguration; 270 | buildSettings = { 271 | CLANG_ENABLE_OBJC_ARC = YES; 272 | COMBINE_HIDPI_IMAGES = YES; 273 | COPY_PHASE_STRIP = NO; 274 | DEBUG_INFORMATION_FORMAT = dwarf; 275 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 276 | ENABLE_NS_ASSERTIONS = YES; 277 | GCC_OPTIMIZATION_LEVEL = 0; 278 | MACOSX_DEPLOYMENT_TARGET = 10.10; 279 | ONLY_ACTIVE_ARCH = YES; 280 | OTHER_SWIFT_FLAGS = "-DXcode"; 281 | PRODUCT_NAME = "$(TARGET_NAME)"; 282 | SDKROOT = macosx; 283 | SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; 284 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = SWIFT_PACKAGE; 285 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 286 | SWIFT_VERSION = 3.0; 287 | USE_HEADERMAP = NO; 288 | }; 289 | name = Debug; 290 | }; 291 | OBJ_31 /* Debug */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; 295 | FRAMEWORK_SEARCH_PATHS = ( 296 | "$(inherited)", 297 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 298 | ); 299 | HEADER_SEARCH_PATHS = "$(inherited)"; 300 | INFOPLIST_FILE = SwiftDSSocket.xcodeproj/SwiftDSSocketTests_Info.plist; 301 | LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/Frameworks"; 302 | OTHER_LDFLAGS = "$(inherited)"; 303 | OTHER_SWIFT_FLAGS = "$(inherited)"; 304 | TARGET_NAME = SwiftDSSocketTests; 305 | }; 306 | name = Debug; 307 | }; 308 | OBJ_32 /* Release */ = { 309 | isa = XCBuildConfiguration; 310 | buildSettings = { 311 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; 312 | FRAMEWORK_SEARCH_PATHS = ( 313 | "$(inherited)", 314 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 315 | ); 316 | HEADER_SEARCH_PATHS = "$(inherited)"; 317 | INFOPLIST_FILE = SwiftDSSocket.xcodeproj/SwiftDSSocketTests_Info.plist; 318 | LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/Frameworks"; 319 | OTHER_LDFLAGS = "$(inherited)"; 320 | OTHER_SWIFT_FLAGS = "$(inherited)"; 321 | TARGET_NAME = SwiftDSSocketTests; 322 | }; 323 | name = Release; 324 | }; 325 | OBJ_4 /* Release */ = { 326 | isa = XCBuildConfiguration; 327 | buildSettings = { 328 | CLANG_ENABLE_OBJC_ARC = YES; 329 | COMBINE_HIDPI_IMAGES = YES; 330 | COPY_PHASE_STRIP = YES; 331 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 332 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 333 | GCC_OPTIMIZATION_LEVEL = s; 334 | MACOSX_DEPLOYMENT_TARGET = 10.10; 335 | OTHER_SWIFT_FLAGS = "-DXcode"; 336 | PRODUCT_NAME = "$(TARGET_NAME)"; 337 | SDKROOT = macosx; 338 | SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; 339 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = SWIFT_PACKAGE; 340 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 341 | SWIFT_VERSION = 3.0; 342 | USE_HEADERMAP = NO; 343 | }; 344 | name = Release; 345 | }; 346 | /* End XCBuildConfiguration section */ 347 | 348 | /* Begin XCConfigurationList section */ 349 | OBJ_2 /* Build configuration list for PBXProject "SwiftDSSocket" */ = { 350 | isa = XCConfigurationList; 351 | buildConfigurations = ( 352 | OBJ_3 /* Debug */, 353 | OBJ_4 /* Release */, 354 | ); 355 | defaultConfigurationIsVisible = 0; 356 | defaultConfigurationName = Debug; 357 | }; 358 | OBJ_23 /* Build configuration list for PBXNativeTarget "SwiftDSSocket" */ = { 359 | isa = XCConfigurationList; 360 | buildConfigurations = ( 361 | OBJ_24 /* Debug */, 362 | OBJ_25 /* Release */, 363 | ); 364 | defaultConfigurationIsVisible = 0; 365 | defaultConfigurationName = Debug; 366 | }; 367 | OBJ_30 /* Build configuration list for PBXNativeTarget "SwiftDSSocketTests" */ = { 368 | isa = XCConfigurationList; 369 | buildConfigurations = ( 370 | OBJ_31 /* Debug */, 371 | OBJ_32 /* Release */, 372 | ); 373 | defaultConfigurationIsVisible = 0; 374 | defaultConfigurationName = Debug; 375 | }; 376 | /* End XCConfigurationList section */ 377 | }; 378 | rootObject = OBJ_1 /* Project object */; 379 | } 380 | -------------------------------------------------------------------------------- /SwiftDSSocket.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftDSSocket.xcodeproj/xcshareddata/xcschemes/SwiftDSSocket.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 55 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 74 | 76 | 77 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /SwiftDSSocket.xcodeproj/xcshareddata/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SchemeUserState 5 | 6 | SwiftDSSocket.xcscheme 7 | 8 | 9 | SuppressBuildableAutocreation 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Tests/SwiftDSSocketTests/CloseAfterReadWrite.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CloseAfterReadWrite.swift 3 | // SwiftDSSocket 4 | // 5 | // Created by Yi Huang on 7/31/17. 6 | // Copyright © 2017 Yi Huang. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftDSSocket 11 | 12 | class CloseAfterReadWrite: XCTestCase { 13 | var client: SwiftDSSocket? 14 | var server: SwiftDSSocket? 15 | var accepted: SwiftDSSocket? 16 | weak var closeAfterAll: XCTestExpectation? 17 | weak var finishWrite: XCTestExpectation? 18 | let serverAdress = "127.0.0.1" 19 | let serverPort: UInt16 = 9999 20 | var dataSent = 0 21 | var dataRecv = 0 22 | let ServerTag = 0 23 | let ClientTag = 1 24 | var buffer: Data = Data() 25 | let testDataLength = 1024 * 1024 26 | let firstPacketSize: UInt = 10 27 | let secondPacketSize: UInt = 5 28 | 29 | override func setUp() { 30 | super.setUp() 31 | client = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 32 | server = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 33 | } 34 | 35 | override func tearDown() { 36 | super.tearDown() 37 | client?.disconnect() 38 | server?.disconnect() 39 | } 40 | 41 | func testExample() { 42 | try? server?.accept(onPort: serverPort) 43 | try? client?.connect(toHost: serverAdress, port: serverPort) 44 | closeAfterAll = expectation(description: "Closed After Read and Write") 45 | finishWrite = expectation(description: "Finished Read Correctly") 46 | 47 | waitForExpectations(timeout: 10) { (error: Error?) in 48 | if let error = error { 49 | XCTFail("Failed Transfer (Unspecified Data Length) error: \(error.localizedDescription)") 50 | } else { 51 | SwiftDSSocket.log("Success") 52 | } 53 | } 54 | } 55 | 56 | } 57 | 58 | extension CloseAfterReadWrite: SwiftDSSocketDelegate { 59 | func socket(sock: SwiftDSSocket, didAcceptNewSocket newSocket: SwiftDSSocket) { 60 | accepted = newSocket 61 | newSocket.readData(toLength: firstPacketSize, tag: ServerTag) 62 | } 63 | 64 | func socket(sock: SwiftDSSocket, didRead data: Data, tag: Int) { 65 | dataRecv += data.count 66 | buffer.append(data) 67 | SwiftDSSocket.log("read Data length = \(data.count) dataRecv = \(dataRecv) should recve = \(testDataLength)") 68 | sock.readData(tag: ServerTag) 69 | } 70 | 71 | func socket(sock: SwiftDSSocket, didConnectToHost host: String, port: UInt16) { 72 | SwiftDSSocket.log("@didConnectToHost") 73 | let dataToSend = Data(count: testDataLength) 74 | sock.write(data: dataToSend, tag: ClientTag) 75 | sock.disconnectAfterReadingAndWriting() 76 | } 77 | 78 | func socket(sock: SwiftDSSocket, didWrite tag: Int) { 79 | SwiftDSSocket.log("@didWrite finsh data transfer") 80 | if tag == ClientTag { 81 | finishWrite?.fulfill() 82 | finishWrite = nil 83 | } 84 | } 85 | 86 | func socket(sock: SwiftDSSocket, didCloseConnection error: SwiftDSSocket.SocketError?) { 87 | if finishWrite == nil { 88 | closeAfterAll?.fulfill() 89 | closeAfterAll = nil 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Tests/SwiftDSSocketTests/ConnectAndListen.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftDSSocketTests.swift 3 | // SwiftDSSocketTests 4 | // 5 | // Created by Yi Huang on 7/27/17. 6 | // Copyright © 2017 Yi Huang. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftDSSocket 11 | 12 | class ConnectAndListen: XCTestCase { 13 | var client: SwiftDSSocket? 14 | var server: SwiftDSSocket? 15 | var accepted: SwiftDSSocket? 16 | weak var onAcceptExpectation: XCTestExpectation? 17 | weak var onConnectExpectation: XCTestExpectation? 18 | let serverAdress = "127.0.0.1" 19 | let serverPort: UInt16 = 9999 20 | 21 | override func setUp() { 22 | super.setUp() 23 | SwiftDSSocket.debugMode = true 24 | client = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 25 | server = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 26 | } 27 | 28 | override func tearDown() { 29 | // Put teardown code here. This method is called after the invocation of each test method in the class. 30 | super.tearDown() 31 | client?.disconnect() 32 | server?.disconnect() 33 | } 34 | 35 | func testExample() { 36 | try? server?.accept(onPort: serverPort) 37 | try? client?.connect(toHost: serverAdress, port: serverPort) 38 | onConnectExpectation = expectation(description: "Test Connect") 39 | onAcceptExpectation = expectation(description: "Test Listen") 40 | 41 | waitForExpectations(timeout: 1) { (error: Error?) in 42 | if let error = error { 43 | XCTFail("failed for error: \(error.localizedDescription)") 44 | } else { 45 | SwiftDSSocket.log("Success") 46 | } 47 | } 48 | } 49 | 50 | } 51 | 52 | 53 | extension ConnectAndListen: SwiftDSSocketDelegate { 54 | func socket(sock: SwiftDSSocket, didAcceptNewSocket newSocket: SwiftDSSocket) { 55 | accepted = newSocket 56 | SwiftDSSocket.log("@didAcceptNewSocket") 57 | onAcceptExpectation?.fulfill() 58 | } 59 | 60 | func socket(sock: SwiftDSSocket, didConnectToHost host: String, port: UInt16) { 61 | SwiftDSSocket.log("@didConnectToHost") 62 | onConnectExpectation?.fulfill() 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Tests/SwiftDSSocketTests/ConnectGoogleIPv6Only.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IPv4and6Connect.swift 3 | // SwiftDSSocket 4 | // 5 | // Created by Yi Huang on 8/6/17. 6 | // 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftDSSocket 11 | 12 | class ConnectGoogleIPv6Only: XCTestCase { 13 | var client: SwiftDSSocket? 14 | var accepted: SwiftDSSocket? 15 | 16 | weak var didConnect: XCTestExpectation? 17 | 18 | let serverAdress = "ipv6.google.com" 19 | let serverPort: UInt16 = 80 20 | 21 | override func setUp() { 22 | super.setUp() 23 | SwiftDSSocket.debugMode = true 24 | client = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 25 | } 26 | 27 | override func tearDown() { 28 | super.tearDown() 29 | client?.disconnect() 30 | } 31 | 32 | // Uncomment the code below if you have a IPv6 test environment 33 | // func testExample() { 34 | // try? client?.connect(toHost: serverAdress, port: serverPort) 35 | // didConnect = expectation(description: "IPv4/6 Connect -> Good") 36 | // 37 | // waitForExpectations(timeout: 5) { (error: Error?) in 38 | // if let error = error { 39 | // XCTFail("failed for error: \(error.localizedDescription)") 40 | // } else { 41 | // SwiftDSSocket.log("Success") 42 | // } 43 | // } 44 | // } 45 | } 46 | 47 | extension ConnectGoogleIPv6Only: SwiftDSSocketDelegate { 48 | func socket(sock: SwiftDSSocket, didConnectToHost host: String, port: UInt16) { 49 | SwiftDSSocket.log("@didConnectToHost") 50 | didConnect?.fulfill() 51 | } 52 | 53 | func socket(sock: SwiftDSSocket, didCloseConnection error: SwiftDSSocket.SocketError?) { 54 | SwiftDSSocket.log("@didCloseConnection") 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Tests/SwiftDSSocketTests/ConnectToWhenPortOff.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftDSSocketTests.swift 3 | // SwiftDSSocketTests 4 | // 5 | // Created by Yi Huang on 7/27/17. 6 | // Copyright © 2017 Yi Huang. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftDSSocket 11 | 12 | class ConnectToWhenPortOff: XCTestCase { 13 | var client: SwiftDSSocket? 14 | var accepted: SwiftDSSocket? 15 | 16 | weak var errorExpectation: XCTestExpectation? 17 | 18 | let serverAdress = "127.0.0.1" 19 | let serverPort: UInt16 = 9999 20 | 21 | override func setUp() { 22 | super.setUp() 23 | SwiftDSSocket.debugMode = true 24 | client = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 25 | } 26 | 27 | override func tearDown() { 28 | // Put teardown code here. This method is called after the invocation of each test method in the class. 29 | super.tearDown() 30 | client?.disconnect() 31 | } 32 | 33 | func testExample() { 34 | try? client?.connect(toHost: serverAdress, port: serverPort) 35 | errorExpectation = expectation(description: "Wait for ECONNREFUSED") 36 | 37 | waitForExpectations(timeout: 1) { (error: Error?) in 38 | if let error = error { 39 | XCTFail("failed for error: \(error.localizedDescription)") 40 | } else { 41 | SwiftDSSocket.log("Success") 42 | } 43 | } 44 | } 45 | 46 | } 47 | 48 | 49 | extension ConnectToWhenPortOff: SwiftDSSocketDelegate { 50 | func socket(sock: SwiftDSSocket, didAcceptNewSocket newSocket: SwiftDSSocket) { 51 | accepted = newSocket 52 | SwiftDSSocket.log("@didAcceptNewSocket") 53 | XCTFail("Should never be called during this test") 54 | } 55 | 56 | func socket(sock: SwiftDSSocket, didConnectToHost host: String, port: UInt16) { 57 | SwiftDSSocket.log("@didConnectToHost") 58 | XCTFail("Should never be called during this test") 59 | } 60 | 61 | func socket(sock: SwiftDSSocket, didCloseConnection error: SwiftDSSocket.SocketError?) { 62 | SwiftDSSocket.log("@didCloseConnection") 63 | let errorCode = error?.socketErrorCode 64 | if errorCode == ECONNREFUSED { 65 | errorExpectation?.fulfill() 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Tests/SwiftDSSocketTests/IPv4and6Connect.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IPv4and6Connect.swift 3 | // SwiftDSSocket 4 | // 5 | // Created by Yi Huang on 8/6/17. 6 | // 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftDSSocket 11 | 12 | class IPv4and6Connect: XCTestCase { 13 | var client: SwiftDSSocket? 14 | var accepted: SwiftDSSocket? 15 | 16 | weak var didConnect: XCTestExpectation? 17 | 18 | let serverAdress = "www.google.com" 19 | let serverPort: UInt16 = 80 20 | 21 | override func setUp() { 22 | super.setUp() 23 | SwiftDSSocket.debugMode = true 24 | client = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 25 | } 26 | 27 | override func tearDown() { 28 | super.tearDown() 29 | client?.disconnect() 30 | } 31 | 32 | func testExample() { 33 | try? client?.connect(toHost: serverAdress, port: serverPort) 34 | didConnect = expectation(description: "IPv4/6 Connect -> Good") 35 | 36 | waitForExpectations(timeout: 5) { (error: Error?) in 37 | if let error = error { 38 | XCTFail("failed for error: \(error.localizedDescription)") 39 | } else { 40 | SwiftDSSocket.log("Success") 41 | } 42 | } 43 | } 44 | } 45 | 46 | extension IPv4and6Connect: SwiftDSSocketDelegate { 47 | func socket(sock: SwiftDSSocket, didConnectToHost host: String, port: UInt16) { 48 | SwiftDSSocket.log("@didConnectToHost") 49 | didConnect?.fulfill() 50 | } 51 | 52 | func socket(sock: SwiftDSSocket, didCloseConnection error: SwiftDSSocket.SocketError?) { 53 | SwiftDSSocket.log("@didCloseConnection") 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Tests/SwiftDSSocketTests/KernelCommunication.swift: -------------------------------------------------------------------------------- 1 | // 2 | // KernelCommunication.swift 3 | // SwiftDSSocket 4 | // 5 | // Created by Yi Huang on 7/31/17. 6 | // Copyright © 2017 Yi Huang. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftDSSocket 11 | 12 | class KernelCommunication: XCTestCase { 13 | var client: SwiftDSSocket? 14 | weak var echoExpectation: XCTestExpectation? 15 | let serverAddress = "com.proximac.kext" 16 | let ClientTag = 1 17 | let packet = "helloworld" 18 | 19 | 20 | override func setUp() { 21 | super.setUp() 22 | client = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .kernel) 23 | } 24 | 25 | override func tearDown() { 26 | super.tearDown() 27 | client?.disconnect() 28 | } 29 | 30 | /*: 31 | **Note:** 32 | Unable to run kernel communication test in CI due to some system restrictions. 33 | 34 | To test this functionality in real system, you need to write a kernel extension. 35 | However, you can try this one written by myself for testing. 36 | 37 | ``` 38 | static errno_t proximac_ctl_send_func(kern_ctl_ref kctlref, u_int32_t unit, void *unitinfo, mbuf_t m, int flags) { 39 | size_t buf_len = mbuf_len(m); 40 | char *data = mbuf_data(m); 41 | ctl_enqueuedata(kctlref, unit, data, buf_len, 0); 42 | mbuf_free(m); 43 | return 0; 44 | } 45 | ``` 46 | Uncomment code below to enable testing in real system 47 | */ 48 | // func testExample() { 49 | // try? client?.tryConnect(tobundleName: serverAddress) 50 | // echoExpectation = expectation(description: "Finished Communication with Kernel") 51 | // waitForExpectations(timeout: 10) { (error) in 52 | // if let error = error { 53 | // XCTFail("Failed Kernel Communication error: \(error.localizedDescription)") 54 | // } 55 | // } 56 | // } 57 | 58 | } 59 | 60 | 61 | extension KernelCommunication: SwiftDSSocketDelegate { 62 | 63 | func socket(sock: SwiftDSSocket, didRead data: Data, tag: Int) { 64 | if data.count == packet.characters.count { 65 | if let content = String(bytes: data, encoding: .utf8) { 66 | if content == packet { 67 | SwiftDSSocket.log("Found data from kernel: \(content)") 68 | echoExpectation?.fulfill() 69 | } 70 | } 71 | } 72 | } 73 | 74 | func socket(sock: SwiftDSSocket, didConnectToHost host: String, port: UInt16) { 75 | SwiftDSSocket.log("@didConnectToHost (kernel)") 76 | let dataToSend = packet.data(using: .utf8) 77 | sock.readData(toLength: UInt(packet.characters.count), tag: ClientTag) 78 | if let dataToSend = dataToSend { 79 | sock.write(data: dataToSend, tag: ClientTag) 80 | } 81 | 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Tests/SwiftDSSocketTests/PartialReadAndWrite.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PartialReadAndWrite 3 | // SwiftDSSocket 4 | // 5 | // Created by Yi Huang on 7/30/17. 6 | // Copyright © 2017 Yi Huang. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftDSSocket 11 | 12 | class PartialReadAndWrite: XCTestCase { 13 | var client: SwiftDSSocket? 14 | var server: SwiftDSSocket? 15 | var accepted: SwiftDSSocket? 16 | weak var finishWrite: XCTestExpectation? 17 | weak var finishRead: XCTestExpectation? 18 | weak var partialWrite: XCTestExpectation? 19 | weak var partialRead: XCTestExpectation? 20 | let serverAdress = "127.0.0.1" 21 | let serverPort: UInt16 = 9999 22 | var dataSent = 0 23 | var dataRecv = 0 24 | let ServerTag = 0 25 | let ClientTag = 1 26 | var buffer: Data = Data() 27 | let testDataLength = 1024 * 1024 * 100 28 | 29 | override func setUp() { 30 | super.setUp() 31 | SwiftDSSocket.debugMode = true 32 | client = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 33 | server = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 34 | } 35 | 36 | override func tearDown() { 37 | super.tearDown() 38 | client?.disconnect() 39 | server?.disconnect() 40 | } 41 | 42 | func testExample() { 43 | try? server?.accept(onPort: serverPort) 44 | try? client?.connect(toHost: serverAdress, port: serverPort) 45 | finishWrite = expectation(description: "Finshed Write Correctlly") 46 | finishRead = expectation(description: "Finshed Read Correctlly") 47 | partialWrite = expectation(description: "Seen Partial Write") 48 | partialRead = expectation(description: "Seen Partial Read") 49 | 50 | waitForExpectations(timeout: 2) { (error: Error?) in 51 | if let error = error { 52 | XCTFail("Failed Transfer (PartialReadAndWrite) error: \(error.localizedDescription)") 53 | } else { 54 | SwiftDSSocket.log("Success") 55 | } 56 | } 57 | } 58 | 59 | 60 | } 61 | 62 | extension PartialReadAndWrite: SwiftDSSocketDelegate { 63 | func socket(sock: SwiftDSSocket, didAcceptNewSocket newSocket: SwiftDSSocket) { 64 | accepted = newSocket 65 | newSocket.readData(toLength: UInt(testDataLength), tag: ServerTag) 66 | } 67 | 68 | func socket(sock: SwiftDSSocket, didPartialRead totalCount: Int, tag: Int) { 69 | // SwiftDSSocket.log("@didPartialRead totalCount = \(totalCount)") 70 | if totalCount < testDataLength { 71 | self.partialRead?.fulfill() 72 | self.partialRead = nil 73 | } 74 | } 75 | 76 | func socket(sock: SwiftDSSocket, didPartialWrite totalCount: Int, tag: Int) { 77 | SwiftDSSocket.log("@didPartialWrite totalCount = \(totalCount)") 78 | if totalCount < testDataLength { 79 | partialWrite?.fulfill() 80 | self.partialWrite = nil 81 | } 82 | } 83 | 84 | func socket(sock: SwiftDSSocket, didRead data: Data, tag: Int) { 85 | dataRecv += data.count 86 | buffer.append(data) 87 | SwiftDSSocket.log("read Data length = \(data.count) dataRecv = \(dataRecv) should recv = \(testDataLength)") 88 | finishRead?.fulfill() 89 | finishRead = nil 90 | } 91 | 92 | func socket(sock: SwiftDSSocket, didConnectToHost host: String, port: UInt16) { 93 | let dataToSend = Data(count: testDataLength) 94 | sock.write(data: dataToSend, tag: ClientTag) 95 | } 96 | 97 | func socket(sock: SwiftDSSocket, didWrite tag: Int) { 98 | SwiftDSSocket.log("@didWrite") 99 | if tag == ClientTag { 100 | finishWrite?.fulfill() 101 | } else { 102 | XCTFail("Write failed due to incorrect tag") 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Tests/SwiftDSSocketTests/TransferSpeciedDataWithGivenBuffer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LargeDataTransferUnspecifiedData.swift 3 | // SwiftDSSocket 4 | // 5 | // Created by Yi Huang on 7/27/17. 6 | // Copyright © 2017 Yi Huang. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftDSSocket 11 | 12 | class TransferSpeciedDataWithGivenBuffer: XCTestCase { 13 | var client: SwiftDSSocket? 14 | var server: SwiftDSSocket? 15 | var accepted: SwiftDSSocket? 16 | weak var finishWrite: XCTestExpectation? 17 | weak var finishRead: XCTestExpectation? 18 | weak var dataCorrect: XCTestExpectation? 19 | let serverAdress = "127.0.0.1" 20 | let serverPort: UInt16 = 9999 21 | var dataSent = 0 22 | var dataRecv = 0 23 | let ServerTag = 31 24 | let ClientTag = 13 25 | var buffer: Data = Data() 26 | let testDataLength = 1024 * 1024 27 | var givenBuffer: UnsafeMutablePointer? 28 | var dataVerifier: UnsafeMutablePointer? 29 | var checksum = 0 30 | 31 | override func setUp() { 32 | super.setUp() 33 | SwiftDSSocket.debugMode = true 34 | client = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 35 | server = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 36 | givenBuffer = UnsafeMutablePointer.allocate(capacity: 2 * testDataLength) 37 | givenBuffer?.initialize(to: UInt8(0), count: testDataLength) 38 | dataVerifier = UnsafeMutablePointer.allocate(capacity: testDataLength) 39 | guard let verifier = dataVerifier else { 40 | XCTFail("Memory is not enough") 41 | return 42 | } 43 | 44 | var sum = 0 45 | for i in 0 ..< testDataLength { 46 | let value = UInt8(arc4random_uniform(255)) 47 | (verifier + i).pointee = value 48 | sum += Int(value) 49 | } 50 | 51 | checksum = sum 52 | SwiftDSSocket.log("Checksum = \(checksum)") 53 | } 54 | 55 | override func tearDown() { 56 | super.tearDown() 57 | client?.disconnect() 58 | server?.disconnect() 59 | } 60 | 61 | func testExample() { 62 | try? server?.accept(onPort: serverPort) 63 | try? client?.connect(toHost: serverAdress, port: serverPort) 64 | finishWrite = expectation(description: "Finshed Write Correctlly") 65 | finishRead = expectation(description: "Finshed Read Correctlly") 66 | dataCorrect = expectation(description: "Data Is Correct") 67 | waitForExpectations(timeout: 2) { (error: Error?) in 68 | if let error = error { 69 | XCTFail("Failed Transfer (Unspecified Data Length) error: \(error.localizedDescription)") 70 | } else { 71 | SwiftDSSocket.log("Success") 72 | } 73 | } 74 | } 75 | 76 | } 77 | 78 | extension TransferSpeciedDataWithGivenBuffer: SwiftDSSocketDelegate { 79 | func socket(sock: SwiftDSSocket, didAcceptNewSocket newSocket: SwiftDSSocket) { 80 | accepted = newSocket 81 | newSocket.readData(toLength: UInt(testDataLength), buffer: givenBuffer!, offset: testDataLength, tag: ServerTag) 82 | } 83 | 84 | func socket(sock: SwiftDSSocket, didRead data: Data, tag: Int) { 85 | SwiftDSSocket.log("@didRead data.count = \(data.count)") 86 | var sum = 0 87 | for i in 0 ..< testDataLength { 88 | sum += Int(data[i]) 89 | } 90 | 91 | SwiftDSSocket.log("Read data checksum = \(sum)") 92 | 93 | 94 | var sumOfZeroRegion = 0 95 | 96 | for i in 0 ..< testDataLength { 97 | sumOfZeroRegion += Int((givenBuffer! + i).pointee) 98 | } 99 | 100 | if sum == checksum && sumOfZeroRegion == 0 { 101 | dataCorrect?.fulfill() 102 | } 103 | 104 | SwiftDSSocket.log("Checksum of first 1kb of givenBuffer = \(sumOfZeroRegion)") 105 | 106 | if data.count == testDataLength { 107 | finishRead?.fulfill() 108 | } 109 | } 110 | 111 | func socket(sock: SwiftDSSocket, didConnectToHost host: String, port: UInt16) { 112 | let dataToSend = Data(bytes: dataVerifier!, count: testDataLength) 113 | sock.write(data: dataToSend, tag: ClientTag) 114 | } 115 | 116 | func socket(sock: SwiftDSSocket, didWrite tag: Int) { 117 | SwiftDSSocket.log("@didWrite") 118 | if tag == ClientTag { 119 | finishWrite?.fulfill() 120 | } else { 121 | XCTFail("Write failed due to incorrect tag") 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /Tests/SwiftDSSocketTests/TransferSpecifiedData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TransferSpecifiedData.swift 3 | // SwiftDSSocket 4 | // 5 | // Created by Yi Huang on 7/30/17. 6 | // Copyright © 2017 Yi Huang. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftDSSocket 11 | 12 | class TransferSpecifiedData: XCTestCase { 13 | var client: SwiftDSSocket? 14 | var server: SwiftDSSocket? 15 | var accepted:SwiftDSSocket? 16 | weak var finishWrite: XCTestExpectation? 17 | weak var finishRead: XCTestExpectation? 18 | let serverAdress = "127.0.0.1" 19 | let serverPort: UInt16 = 9999 20 | var dataSent = 0 21 | var dataRecv = 0 22 | let ServerTag = 0 23 | let ClientTag = 1 24 | var buffer: Data = Data() 25 | let testDataLength = 1024 * 1024 26 | let firstPacketSize: UInt = 10 27 | let secondPacketSize: UInt = 5 28 | var testTuples = [(UInt, XCTestExpectation)]() 29 | 30 | override func setUp() { 31 | super.setUp() 32 | client = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 33 | server = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 34 | } 35 | 36 | override func tearDown() { 37 | super.tearDown() 38 | client?.disconnect() 39 | server?.disconnect() 40 | } 41 | 42 | func testExample() { 43 | try? server?.accept(onPort: serverPort) 44 | try? client?.connect(toHost: serverAdress, port: serverPort) 45 | finishWrite = expectation(description: "Finshed Write Correctlly") 46 | let seq: [UInt] = [firstPacketSize, secondPacketSize] 47 | 48 | for len in seq { 49 | testTuples.insert((len, expectation(description: "Finshed Read \(len)")), at: 0) 50 | } 51 | 52 | waitForExpectations(timeout: 30) { (error: Error?) in 53 | if let error = error { 54 | XCTFail("Failed Transfer (Unspecified Data Length) error: \(error.localizedDescription)") 55 | } else { 56 | SwiftDSSocket.log("Success") 57 | } 58 | } 59 | } 60 | 61 | 62 | 63 | } 64 | 65 | extension TransferSpecifiedData: SwiftDSSocketDelegate { 66 | func socket(sock: SwiftDSSocket, didAcceptNewSocket newSocket: SwiftDSSocket) { 67 | accepted = newSocket 68 | newSocket.readData(toLength: firstPacketSize, tag: ServerTag) 69 | } 70 | 71 | func socket(sock: SwiftDSSocket, didRead data: Data, tag: Int) { 72 | dataRecv += data.count 73 | buffer.append(data) 74 | SwiftDSSocket.log("read Data length = \(data.count) dataRecv = \(dataRecv) should recve = \(testDataLength)") 75 | if let tuple = testTuples.popLast() { 76 | if tuple.0 == UInt(data.count) { 77 | tuple.1.fulfill() 78 | } 79 | } else { 80 | XCTFail("Unknown data found") 81 | } 82 | sock.readData(toLength: secondPacketSize, tag: ServerTag) 83 | } 84 | 85 | func socket(sock: SwiftDSSocket, didConnectToHost host: String, port: UInt16) { 86 | let rawDataArray: [UInt8] = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 2, 4, 6, 8, 10] 87 | let dataToSend = Data(bytes: rawDataArray) 88 | sock.write(data: dataToSend, tag: ClientTag) 89 | } 90 | 91 | func socket(sock: SwiftDSSocket, didWrite tag: Int) { 92 | SwiftDSSocket.log("@didWrite") 93 | if tag == ClientTag { 94 | finishWrite?.fulfill() 95 | } else { 96 | XCTFail("Write failed due to incorrect tag") 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Tests/SwiftDSSocketTests/TransferUnspecifiedData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LargeDataTransferUnspecifiedData.swift 3 | // SwiftDSSocket 4 | // 5 | // Created by Yi Huang on 7/27/17. 6 | // Copyright © 2017 Yi Huang. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftDSSocket 11 | 12 | class TransferUnspecifiedData: XCTestCase { 13 | var client: SwiftDSSocket? 14 | var server: SwiftDSSocket? 15 | var accepted: SwiftDSSocket? 16 | weak var finishWrite: XCTestExpectation? 17 | weak var finishRead: XCTestExpectation? 18 | let serverAdress = "127.0.0.1" 19 | let serverPort: UInt16 = 9999 20 | var dataSent = 0 21 | var dataRecv = 0 22 | let ServerTag = 0 23 | let ClientTag = 1 24 | var buffer: Data = Data() 25 | let testDataLength = 1024 * 1024 26 | 27 | override func setUp() { 28 | super.setUp() 29 | client = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 30 | server = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp) 31 | } 32 | 33 | override func tearDown() { 34 | super.tearDown() 35 | client?.disconnect() 36 | server?.disconnect() 37 | } 38 | 39 | func testExample() { 40 | try? server?.accept(onPort: serverPort) 41 | try? client?.connect(toHost: serverAdress, port: serverPort) 42 | finishWrite = expectation(description: "Finshed Write Correctlly") 43 | finishRead = expectation(description: "Finshed Read Correctlly") 44 | 45 | waitForExpectations(timeout: 30) { (error: Error?) in 46 | if let error = error { 47 | XCTFail("Failed Transfer (Unspecified Data Length) error: \(error.localizedDescription)") 48 | } else { 49 | SwiftDSSocket.log("Success") 50 | } 51 | } 52 | } 53 | 54 | 55 | } 56 | 57 | extension TransferUnspecifiedData: SwiftDSSocketDelegate { 58 | func socket(sock: SwiftDSSocket, didAcceptNewSocket newSocket: SwiftDSSocket) { 59 | accepted = newSocket 60 | newSocket.readData(tag: ServerTag) 61 | } 62 | 63 | func socket(sock: SwiftDSSocket, didRead data: Data, tag: Int) { 64 | dataRecv += data.count 65 | buffer.append(data) 66 | SwiftDSSocket.log("read Data length = \(data.count) dataRecv = \(dataRecv) should recve = \(testDataLength)") 67 | if dataRecv == testDataLength { 68 | finishRead?.fulfill() 69 | } 70 | sock.readData(tag: ServerTag) 71 | } 72 | 73 | func socket(sock: SwiftDSSocket, didConnectToHost host: String, port: UInt16) { 74 | let dataToSend = Data(count: testDataLength) 75 | sock.write(data: dataToSend, tag: ClientTag) 76 | } 77 | 78 | func socket(sock: SwiftDSSocket, didWrite tag: Int) { 79 | SwiftDSSocket.log("@didWrite") 80 | if tag == ClientTag { 81 | finishWrite?.fulfill() 82 | } else { 83 | XCTFail("Write failed due to incorrect tag") 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /docs/Classes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Classes Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |

SwiftDSSocket Docs (64% documented)

17 |
18 |
19 |
20 | 25 |
26 |
27 | 53 |
54 |
55 |
56 |

Classes

57 |

The following classes are available globally.

58 | 59 |
60 |
61 |
62 |
    63 |
  • 64 |
    65 | 66 | 67 | 68 | SwiftDSSocket 69 | 70 |
    71 |
    72 |
    73 |
    74 |
    75 |
    76 |

    SwiftDSSocket class definition

    77 | 78 | See more 79 |
    80 |
    81 |

    Declaration

    82 |
    83 |

    Swift

    84 |
    public class SwiftDSSocket: NSObject
    85 | 86 |
    87 |
    88 |
    89 |
    90 |
  • 91 |
92 |
93 |
94 |
95 | 99 |
100 |
101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /docs/Classes/SwiftDSSocket/SocketError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SocketError Class Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftDSSocket Docs (64% documented)

18 |
19 |
20 |
21 | 26 |
27 |
28 | 54 |
55 |
56 |
57 |

SocketError

58 |
59 |
60 |
public class SocketError: NSObject, Error
61 | 62 |
63 |
64 |

this defines all kinds of error in SwiftDSSocket

65 | 66 |
67 |
68 |
69 |
    70 |
  • 71 |
    72 | 73 | 74 | 75 | ErrorKind 76 | 77 |
    78 |
    79 |
    80 |
    81 |
    82 |
    83 |

    Kinds of Error in SocketError

    84 | 85 |
      86 |
    • socketErrorFCNTL: failure in BSD fcntl function
    • 87 |
    • socketErrorDefault: default error
    • 88 |
    • socketErrorIOCTL: failure in BSD ioctl function
    • 89 |
    • socketErrorWrongAddress: the given address is not correct
    • 90 |
    • socketErrorAlreadyConnected: the current socket is already connected
    • 91 |
    • socketErrorIncorrectSocketStatus: conflicts with current socket status
    • 92 |
    • socketErrorConnecting: failure in connecting to destination
    • 93 |
    • socketErrorReadSpecific: found error when reading data from sock (return from read)
    • 94 |
    • socketErrorWriteSpecific: found error when writing data to sock (return from write)
    • 95 |
    • socketErrorSetSockOpt: failure in BSD setsockopt function
    • 96 |
    97 | 98 | See more 99 |
    100 |
    101 |

    Declaration

    102 |
    103 |

    Swift

    104 |
    public enum ErrorKind
    105 | 106 |
    107 |
    108 |
    109 |
    110 |
  • 111 |
  • 112 |
    113 | 114 | 115 | 116 | errorKind 117 | 118 |
    119 |
    120 |
    121 |
    122 |
    123 |
    124 |

    specifies error kind

    125 | 126 |
    127 |
    128 |

    Declaration

    129 |
    130 |

    Swift

    131 |
    public var errorKind: ErrorKind?
    132 | 133 |
    134 |
    135 |
    136 |
    137 |
  • 138 |
  • 139 |
    140 | 141 | 142 | 143 | socketErrorCode 144 | 145 |
    146 |
    147 |
    148 |
    149 |
    150 |
    151 |

    specifies error code (only for BSD socket standard error code)

    152 | 153 |
    154 |
    155 |

    Declaration

    156 |
    157 |

    Swift

    158 |
    public var socketErrorCode: Int32
    159 | 160 |
    161 |
    162 |
    163 |
    164 |
  • 165 |
  • 166 |
    167 | 168 | 169 | 170 | localizedDescription 171 | 172 |
    173 |
    174 |
    175 |
    176 |
    177 |
    178 |

    a description string for this error

    179 | 180 |
    181 |
    182 |

    Declaration

    183 |
    184 |

    Swift

    185 |
    public var localizedDescription: String?
    186 | 187 |
    188 |
    189 |
    190 |
    191 |
  • 192 |
193 |
194 |
195 |
196 | 200 |
201 |
202 | 203 | 204 | 205 | -------------------------------------------------------------------------------- /docs/Classes/SwiftDSSocket/SocketType.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SocketType Enum Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftDSSocket Docs (64% documented)

18 |
19 |
20 |
21 | 26 |
27 |
28 | 54 |
55 |
56 |
57 |

SocketType

58 |
59 |
60 |
public enum SocketType
61 | 62 |
63 |
64 |

Socket Type

65 | 66 |
    67 |
  • tcp: for TCP stream
  • 68 |
  • kernel: for kernel TCP stream
  • 69 |
70 | 71 |
72 |
73 |
74 |
    75 |
  • 76 |
    77 | 78 | 79 | 80 | tcp 81 | 82 |
    83 |
    84 |
    85 |
    86 |
    87 |
    88 |

    Undocumented

    89 | 90 |
    91 |
    92 |

    Declaration

    93 |
    94 |

    Swift

    95 |
    public enum SocketType
    96 | 97 |
    98 |
    99 |
    100 |
    101 |
  • 102 |
103 |
104 |
105 |
    106 |
  • 107 |
    108 | 109 | 110 | 111 | kernel 112 | 113 |
    114 |
    115 |
    116 |
    117 |
    118 |
    119 |

    Undocumented

    120 | 121 |
    122 |
    123 |

    Declaration

    124 |
    125 |

    Swift

    126 |
    public enum SocketType
    127 | 128 |
    129 |
    130 |
    131 |
    132 |
  • 133 |
134 |
135 |
136 |
137 | 141 |
142 |
143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /docs/Protocols.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Protocols Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |

SwiftDSSocket Docs (64% documented)

17 |
18 |
19 |
20 | 25 |
26 |
27 | 53 |
54 |
55 |
56 |

Protocols

57 |

The following protocols are available globally.

58 | 59 |
60 |
61 |
62 |
    63 |
  • 64 |
    65 | 66 | 67 | 68 | SwiftDSSocketDelegate 69 | 70 |
    71 |
    72 |
    73 |
    74 |
    75 |
    76 |

    delegate methods for each operation

    77 | 78 | See more 79 |
    80 |
    81 |

    Declaration

    82 |
    83 |

    Swift

    84 |
    @objc public protocol SwiftDSSocketDelegate
    85 | 86 |
    87 |
    88 |
    89 |
    90 |
  • 91 |
92 |
93 |
94 |
95 | 99 |
100 |
101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /docs/badge.svg: -------------------------------------------------------------------------------- 1 | documentationdocumentation64%64% -------------------------------------------------------------------------------- /docs/css/highlight.css: -------------------------------------------------------------------------------- 1 | /* Credit to https://gist.github.com/wataru420/2048287 */ 2 | .highlight { 3 | /* Comment */ 4 | /* Error */ 5 | /* Keyword */ 6 | /* Operator */ 7 | /* Comment.Multiline */ 8 | /* Comment.Preproc */ 9 | /* Comment.Single */ 10 | /* Comment.Special */ 11 | /* Generic.Deleted */ 12 | /* Generic.Deleted.Specific */ 13 | /* Generic.Emph */ 14 | /* Generic.Error */ 15 | /* Generic.Heading */ 16 | /* Generic.Inserted */ 17 | /* Generic.Inserted.Specific */ 18 | /* Generic.Output */ 19 | /* Generic.Prompt */ 20 | /* Generic.Strong */ 21 | /* Generic.Subheading */ 22 | /* Generic.Traceback */ 23 | /* Keyword.Constant */ 24 | /* Keyword.Declaration */ 25 | /* Keyword.Pseudo */ 26 | /* Keyword.Reserved */ 27 | /* Keyword.Type */ 28 | /* Literal.Number */ 29 | /* Literal.String */ 30 | /* Name.Attribute */ 31 | /* Name.Builtin */ 32 | /* Name.Class */ 33 | /* Name.Constant */ 34 | /* Name.Entity */ 35 | /* Name.Exception */ 36 | /* Name.Function */ 37 | /* Name.Namespace */ 38 | /* Name.Tag */ 39 | /* Name.Variable */ 40 | /* Operator.Word */ 41 | /* Text.Whitespace */ 42 | /* Literal.Number.Float */ 43 | /* Literal.Number.Hex */ 44 | /* Literal.Number.Integer */ 45 | /* Literal.Number.Oct */ 46 | /* Literal.String.Backtick */ 47 | /* Literal.String.Char */ 48 | /* Literal.String.Doc */ 49 | /* Literal.String.Double */ 50 | /* Literal.String.Escape */ 51 | /* Literal.String.Heredoc */ 52 | /* Literal.String.Interpol */ 53 | /* Literal.String.Other */ 54 | /* Literal.String.Regex */ 55 | /* Literal.String.Single */ 56 | /* Literal.String.Symbol */ 57 | /* Name.Builtin.Pseudo */ 58 | /* Name.Variable.Class */ 59 | /* Name.Variable.Global */ 60 | /* Name.Variable.Instance */ 61 | /* Literal.Number.Integer.Long */ } 62 | .highlight .c { 63 | color: #999988; 64 | font-style: italic; } 65 | .highlight .err { 66 | color: #a61717; 67 | background-color: #e3d2d2; } 68 | .highlight .k { 69 | color: #000000; 70 | font-weight: bold; } 71 | .highlight .o { 72 | color: #000000; 73 | font-weight: bold; } 74 | .highlight .cm { 75 | color: #999988; 76 | font-style: italic; } 77 | .highlight .cp { 78 | color: #999999; 79 | font-weight: bold; } 80 | .highlight .c1 { 81 | color: #999988; 82 | font-style: italic; } 83 | .highlight .cs { 84 | color: #999999; 85 | font-weight: bold; 86 | font-style: italic; } 87 | .highlight .gd { 88 | color: #000000; 89 | background-color: #ffdddd; } 90 | .highlight .gd .x { 91 | color: #000000; 92 | background-color: #ffaaaa; } 93 | .highlight .ge { 94 | color: #000000; 95 | font-style: italic; } 96 | .highlight .gr { 97 | color: #aa0000; } 98 | .highlight .gh { 99 | color: #999999; } 100 | .highlight .gi { 101 | color: #000000; 102 | background-color: #ddffdd; } 103 | .highlight .gi .x { 104 | color: #000000; 105 | background-color: #aaffaa; } 106 | .highlight .go { 107 | color: #888888; } 108 | .highlight .gp { 109 | color: #555555; } 110 | .highlight .gs { 111 | font-weight: bold; } 112 | .highlight .gu { 113 | color: #aaaaaa; } 114 | .highlight .gt { 115 | color: #aa0000; } 116 | .highlight .kc { 117 | color: #000000; 118 | font-weight: bold; } 119 | .highlight .kd { 120 | color: #000000; 121 | font-weight: bold; } 122 | .highlight .kp { 123 | color: #000000; 124 | font-weight: bold; } 125 | .highlight .kr { 126 | color: #000000; 127 | font-weight: bold; } 128 | .highlight .kt { 129 | color: #445588; } 130 | .highlight .m { 131 | color: #009999; } 132 | .highlight .s { 133 | color: #d14; } 134 | .highlight .na { 135 | color: #008080; } 136 | .highlight .nb { 137 | color: #0086B3; } 138 | .highlight .nc { 139 | color: #445588; 140 | font-weight: bold; } 141 | .highlight .no { 142 | color: #008080; } 143 | .highlight .ni { 144 | color: #800080; } 145 | .highlight .ne { 146 | color: #990000; 147 | font-weight: bold; } 148 | .highlight .nf { 149 | color: #990000; } 150 | .highlight .nn { 151 | color: #555555; } 152 | .highlight .nt { 153 | color: #000080; } 154 | .highlight .nv { 155 | color: #008080; } 156 | .highlight .ow { 157 | color: #000000; 158 | font-weight: bold; } 159 | .highlight .w { 160 | color: #bbbbbb; } 161 | .highlight .mf { 162 | color: #009999; } 163 | .highlight .mh { 164 | color: #009999; } 165 | .highlight .mi { 166 | color: #009999; } 167 | .highlight .mo { 168 | color: #009999; } 169 | .highlight .sb { 170 | color: #d14; } 171 | .highlight .sc { 172 | color: #d14; } 173 | .highlight .sd { 174 | color: #d14; } 175 | .highlight .s2 { 176 | color: #d14; } 177 | .highlight .se { 178 | color: #d14; } 179 | .highlight .sh { 180 | color: #d14; } 181 | .highlight .si { 182 | color: #d14; } 183 | .highlight .sx { 184 | color: #d14; } 185 | .highlight .sr { 186 | color: #009926; } 187 | .highlight .s1 { 188 | color: #d14; } 189 | .highlight .ss { 190 | color: #990073; } 191 | .highlight .bp { 192 | color: #999999; } 193 | .highlight .vc { 194 | color: #008080; } 195 | .highlight .vg { 196 | color: #008080; } 197 | .highlight .vi { 198 | color: #008080; } 199 | .highlight .il { 200 | color: #009999; } 201 | -------------------------------------------------------------------------------- /docs/css/jazzy.css: -------------------------------------------------------------------------------- 1 | html, body, div, span, h1, h3, h4, p, a, code, em, img, ul, li, table, tbody, tr, td { 2 | background: transparent; 3 | border: 0; 4 | margin: 0; 5 | outline: 0; 6 | padding: 0; 7 | vertical-align: baseline; } 8 | 9 | body { 10 | background-color: #f2f2f2; 11 | font-family: Helvetica, freesans, Arial, sans-serif; 12 | font-size: 14px; 13 | -webkit-font-smoothing: subpixel-antialiased; 14 | word-wrap: break-word; } 15 | 16 | h1, h2, h3 { 17 | margin-top: 0.8em; 18 | margin-bottom: 0.3em; 19 | font-weight: 100; 20 | color: black; } 21 | 22 | h1 { 23 | font-size: 2.5em; } 24 | 25 | h2 { 26 | font-size: 2em; 27 | border-bottom: 1px solid #e2e2e2; } 28 | 29 | h4 { 30 | font-size: 13px; 31 | line-height: 1.5; 32 | margin-top: 21px; } 33 | 34 | h5 { 35 | font-size: 1.1em; } 36 | 37 | h6 { 38 | font-size: 1.1em; 39 | color: #777; } 40 | 41 | .section-name { 42 | color: gray; 43 | display: block; 44 | font-family: Helvetica; 45 | font-size: 22px; 46 | font-weight: 100; 47 | margin-bottom: 15px; } 48 | 49 | pre, code { 50 | font: 0.95em Menlo, monospace; 51 | color: #777; 52 | word-wrap: normal; } 53 | 54 | p code, li code { 55 | background-color: #eee; 56 | padding: 2px 4px; 57 | border-radius: 4px; } 58 | 59 | a { 60 | color: #0088cc; 61 | text-decoration: none; } 62 | 63 | ul { 64 | padding-left: 15px; } 65 | 66 | li { 67 | line-height: 1.8em; } 68 | 69 | img { 70 | max-width: 100%; } 71 | 72 | blockquote { 73 | margin-left: 0; 74 | padding: 0 10px; 75 | border-left: 4px solid #ccc; } 76 | 77 | .content-wrapper { 78 | margin: 0 auto; 79 | width: 980px; } 80 | 81 | header { 82 | font-size: 0.85em; 83 | line-height: 26px; 84 | background-color: #414141; 85 | position: fixed; 86 | width: 100%; 87 | z-index: 1; } 88 | header img { 89 | padding-right: 6px; 90 | vertical-align: -4px; 91 | height: 16px; } 92 | header a { 93 | color: #fff; } 94 | header p { 95 | float: left; 96 | color: #999; } 97 | header .header-right { 98 | float: right; 99 | margin-left: 16px; } 100 | 101 | #breadcrumbs { 102 | background-color: #f2f2f2; 103 | height: 27px; 104 | padding-top: 17px; 105 | position: fixed; 106 | width: 100%; 107 | z-index: 1; 108 | margin-top: 26px; } 109 | #breadcrumbs #carat { 110 | height: 10px; 111 | margin: 0 5px; } 112 | 113 | .sidebar { 114 | background-color: #f9f9f9; 115 | border: 1px solid #e2e2e2; 116 | overflow-y: auto; 117 | overflow-x: hidden; 118 | position: fixed; 119 | top: 70px; 120 | bottom: 0; 121 | width: 230px; 122 | word-wrap: normal; } 123 | 124 | .nav-groups { 125 | list-style-type: none; 126 | background: #fff; 127 | padding-left: 0; } 128 | 129 | .nav-group-name { 130 | border-bottom: 1px solid #e2e2e2; 131 | font-size: 1.1em; 132 | font-weight: 100; 133 | padding: 15px 0 15px 20px; } 134 | .nav-group-name > a { 135 | color: #333; } 136 | 137 | .nav-group-tasks { 138 | margin-top: 5px; } 139 | 140 | .nav-group-task { 141 | font-size: 0.9em; 142 | list-style-type: none; 143 | white-space: nowrap; } 144 | .nav-group-task a { 145 | color: #888; } 146 | 147 | .main-content { 148 | background-color: #fff; 149 | border: 1px solid #e2e2e2; 150 | margin-left: 246px; 151 | position: absolute; 152 | overflow: hidden; 153 | padding-bottom: 60px; 154 | top: 70px; 155 | width: 734px; } 156 | .main-content p, .main-content a, .main-content code, .main-content em, .main-content ul, .main-content table, .main-content blockquote { 157 | margin-bottom: 1em; } 158 | .main-content p { 159 | line-height: 1.8em; } 160 | .main-content section .section:first-child { 161 | margin-top: 0; 162 | padding-top: 0; } 163 | .main-content section .task-group-section .task-group:first-of-type { 164 | padding-top: 10px; } 165 | .main-content section .task-group-section .task-group:first-of-type .section-name { 166 | padding-top: 15px; } 167 | .main-content section .heading:before { 168 | content: ""; 169 | display: block; 170 | padding-top: 70px; 171 | margin: -70px 0 0; } 172 | 173 | .section { 174 | padding: 0 25px; } 175 | 176 | .highlight { 177 | background-color: #eee; 178 | padding: 10px 12px; 179 | border: 1px solid #e2e2e2; 180 | border-radius: 4px; 181 | overflow-x: auto; } 182 | 183 | .declaration .highlight { 184 | overflow-x: initial; 185 | padding: 0 40px 40px 0; 186 | margin-bottom: -25px; 187 | background-color: transparent; 188 | border: none; } 189 | 190 | .section-name { 191 | margin: 0; 192 | margin-left: 18px; } 193 | 194 | .task-group-section { 195 | padding-left: 6px; 196 | border-top: 1px solid #e2e2e2; } 197 | 198 | .task-group { 199 | padding-top: 0px; } 200 | 201 | .task-name-container a[name]:before { 202 | content: ""; 203 | display: block; 204 | padding-top: 70px; 205 | margin: -70px 0 0; } 206 | 207 | .item { 208 | padding-top: 8px; 209 | width: 100%; 210 | list-style-type: none; } 211 | .item a[name]:before { 212 | content: ""; 213 | display: block; 214 | padding-top: 70px; 215 | margin: -70px 0 0; } 216 | .item code { 217 | background-color: transparent; 218 | padding: 0; } 219 | .item .token { 220 | padding-left: 3px; 221 | margin-left: 15px; 222 | font-size: 11.9px; } 223 | .item .declaration-note { 224 | font-size: .85em; 225 | color: gray; 226 | font-style: italic; } 227 | 228 | .pointer-container { 229 | border-bottom: 1px solid #e2e2e2; 230 | left: -23px; 231 | padding-bottom: 13px; 232 | position: relative; 233 | width: 110%; } 234 | 235 | .pointer { 236 | background: #f9f9f9; 237 | border-left: 1px solid #e2e2e2; 238 | border-top: 1px solid #e2e2e2; 239 | height: 12px; 240 | left: 21px; 241 | top: -7px; 242 | -webkit-transform: rotate(45deg); 243 | -moz-transform: rotate(45deg); 244 | -o-transform: rotate(45deg); 245 | transform: rotate(45deg); 246 | position: absolute; 247 | width: 12px; } 248 | 249 | .height-container { 250 | display: none; 251 | left: -25px; 252 | padding: 0 25px; 253 | position: relative; 254 | width: 100%; 255 | overflow: hidden; } 256 | .height-container .section { 257 | background: #f9f9f9; 258 | border-bottom: 1px solid #e2e2e2; 259 | left: -25px; 260 | position: relative; 261 | width: 100%; 262 | padding-top: 10px; 263 | padding-bottom: 5px; } 264 | 265 | .aside, .language { 266 | padding: 6px 12px; 267 | margin: 12px 0; 268 | border-left: 5px solid #dddddd; 269 | overflow-y: hidden; } 270 | .aside .aside-title, .language .aside-title { 271 | font-size: 9px; 272 | letter-spacing: 2px; 273 | text-transform: uppercase; 274 | padding-bottom: 0; 275 | margin: 0; 276 | color: #aaa; 277 | -webkit-user-select: none; } 278 | .aside p:last-child, .language p:last-child { 279 | margin-bottom: 0; } 280 | 281 | .language { 282 | border-left: 5px solid #cde9f4; } 283 | .language .aside-title { 284 | color: #4b8afb; } 285 | 286 | .aside-warning { 287 | border-left: 5px solid #ff6666; } 288 | .aside-warning .aside-title { 289 | color: #ff0000; } 290 | 291 | .graybox { 292 | border-collapse: collapse; 293 | width: 100%; } 294 | .graybox p { 295 | margin: 0; 296 | word-break: break-word; 297 | min-width: 50px; } 298 | .graybox td { 299 | border: 1px solid #e2e2e2; 300 | padding: 5px 25px 5px 10px; 301 | vertical-align: middle; } 302 | .graybox tr td:first-of-type { 303 | text-align: right; 304 | padding: 7px; 305 | vertical-align: top; 306 | word-break: normal; 307 | width: 40px; } 308 | 309 | .slightly-smaller { 310 | font-size: 0.9em; } 311 | 312 | #footer { 313 | position: absolute; 314 | bottom: 10px; 315 | margin-left: 25px; } 316 | #footer p { 317 | margin: 0; 318 | color: #aaa; 319 | font-size: 0.8em; } 320 | 321 | html.dash header, html.dash #breadcrumbs, html.dash .sidebar { 322 | display: none; } 323 | html.dash .main-content { 324 | width: 980px; 325 | margin-left: 0; 326 | border: none; 327 | width: 100%; 328 | top: 0; 329 | padding-bottom: 0; } 330 | html.dash .height-container { 331 | display: block; } 332 | html.dash .item .token { 333 | margin-left: 0; } 334 | html.dash .content-wrapper { 335 | width: auto; } 336 | html.dash #footer { 337 | position: static; } 338 | -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleIdentifier 6 | com.jazzy.swiftdssocket 7 | CFBundleName 8 | SwiftDSSocket 9 | DocSetPlatformFamily 10 | swiftdssocket 11 | isDashDocset 12 | 13 | dashIndexFilePath 14 | index.html 15 | isJavaScriptEnabled 16 | 17 | DashDocSetFamily 18 | dashtoc 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/Classes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Classes Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |

SwiftDSSocket Docs (64% documented)

17 |
18 |
19 |
20 | 25 |
26 |
27 | 53 |
54 |
55 |
56 |

Classes

57 |

The following classes are available globally.

58 | 59 |
60 |
61 |
62 |
    63 |
  • 64 |
    65 | 66 | 67 | 68 | SwiftDSSocket 69 | 70 |
    71 |
    72 |
    73 |
    74 |
    75 |
    76 |

    SwiftDSSocket class definition

    77 | 78 | See more 79 |
    80 |
    81 |

    Declaration

    82 |
    83 |

    Swift

    84 |
    public class SwiftDSSocket: NSObject
    85 | 86 |
    87 |
    88 |
    89 |
    90 |
  • 91 |
92 |
93 |
94 |
95 | 99 |
100 |
101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/Classes/SwiftDSSocket/SocketError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SocketError Class Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftDSSocket Docs (64% documented)

18 |
19 |
20 |
21 | 26 |
27 |
28 | 54 |
55 |
56 |
57 |

SocketError

58 |
59 |
60 |
public class SocketError: NSObject, Error
61 | 62 |
63 |
64 |

this defines all kinds of error in SwiftDSSocket

65 | 66 |
67 |
68 |
69 |
    70 |
  • 71 |
    72 | 73 | 74 | 75 | ErrorKind 76 | 77 |
    78 |
    79 |
    80 |
    81 |
    82 |
    83 |

    Kinds of Error in SocketError

    84 | 85 |
      86 |
    • socketErrorFCNTL: failure in BSD fcntl function
    • 87 |
    • socketErrorDefault: default error
    • 88 |
    • socketErrorIOCTL: failure in BSD ioctl function
    • 89 |
    • socketErrorWrongAddress: the given address is not correct
    • 90 |
    • socketErrorAlreadyConnected: the current socket is already connected
    • 91 |
    • socketErrorIncorrectSocketStatus: conflicts with current socket status
    • 92 |
    • socketErrorConnecting: failure in connecting to destination
    • 93 |
    • socketErrorReadSpecific: found error when reading data from sock (return from read)
    • 94 |
    • socketErrorWriteSpecific: found error when writing data to sock (return from write)
    • 95 |
    • socketErrorSetSockOpt: failure in BSD setsockopt function
    • 96 |
    97 | 98 | See more 99 |
    100 |
    101 |

    Declaration

    102 |
    103 |

    Swift

    104 |
    public enum ErrorKind
    105 | 106 |
    107 |
    108 |
    109 |
    110 |
  • 111 |
  • 112 |
    113 | 114 | 115 | 116 | errorKind 117 | 118 |
    119 |
    120 |
    121 |
    122 |
    123 |
    124 |

    specifies error kind

    125 | 126 |
    127 |
    128 |

    Declaration

    129 |
    130 |

    Swift

    131 |
    public var errorKind: ErrorKind?
    132 | 133 |
    134 |
    135 |
    136 |
    137 |
  • 138 |
  • 139 |
    140 | 141 | 142 | 143 | socketErrorCode 144 | 145 |
    146 |
    147 |
    148 |
    149 |
    150 |
    151 |

    specifies error code (only for BSD socket standard error code)

    152 | 153 |
    154 |
    155 |

    Declaration

    156 |
    157 |

    Swift

    158 |
    public var socketErrorCode: Int32
    159 | 160 |
    161 |
    162 |
    163 |
    164 |
  • 165 |
  • 166 |
    167 | 168 | 169 | 170 | localizedDescription 171 | 172 |
    173 |
    174 |
    175 |
    176 |
    177 |
    178 |

    a description string for this error

    179 | 180 |
    181 |
    182 |

    Declaration

    183 |
    184 |

    Swift

    185 |
    public var localizedDescription: String?
    186 | 187 |
    188 |
    189 |
    190 |
    191 |
  • 192 |
193 |
194 |
195 |
196 | 200 |
201 |
202 | 203 | 204 | 205 | -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/Classes/SwiftDSSocket/SocketType.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SocketType Enum Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftDSSocket Docs (64% documented)

18 |
19 |
20 |
21 | 26 |
27 |
28 | 54 |
55 |
56 |
57 |

SocketType

58 |
59 |
60 |
public enum SocketType
61 | 62 |
63 |
64 |

Socket Type

65 | 66 |
    67 |
  • tcp: for TCP stream
  • 68 |
  • kernel: for kernel TCP stream
  • 69 |
70 | 71 |
72 |
73 |
74 |
    75 |
  • 76 |
    77 | 78 | 79 | 80 | tcp 81 | 82 |
    83 |
    84 |
    85 |
    86 |
    87 |
    88 |

    Undocumented

    89 | 90 |
    91 |
    92 |

    Declaration

    93 |
    94 |

    Swift

    95 |
    public enum SocketType
    96 | 97 |
    98 |
    99 |
    100 |
    101 |
  • 102 |
103 |
104 |
105 |
    106 |
  • 107 |
    108 | 109 | 110 | 111 | kernel 112 | 113 |
    114 |
    115 |
    116 |
    117 |
    118 |
    119 |

    Undocumented

    120 | 121 |
    122 |
    123 |

    Declaration

    124 |
    125 |

    Swift

    126 |
    public enum SocketType
    127 | 128 |
    129 |
    130 |
    131 |
    132 |
  • 133 |
134 |
135 |
136 |
137 | 141 |
142 |
143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/Protocols.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Protocols Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |

SwiftDSSocket Docs (64% documented)

17 |
18 |
19 |
20 | 25 |
26 |
27 | 53 |
54 |
55 |
56 |

Protocols

57 |

The following protocols are available globally.

58 | 59 |
60 |
61 |
62 |
    63 |
  • 64 |
    65 | 66 | 67 | 68 | SwiftDSSocketDelegate 69 | 70 |
    71 |
    72 |
    73 |
    74 |
    75 |
    76 |

    delegate methods for each operation

    77 | 78 | See more 79 |
    80 |
    81 |

    Declaration

    82 |
    83 |

    Swift

    84 |
    @objc public protocol SwiftDSSocketDelegate
    85 | 86 |
    87 |
    88 |
    89 |
    90 |
  • 91 |
92 |
93 |
94 |
95 | 99 |
100 |
101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/badge.svg: -------------------------------------------------------------------------------- 1 | documentationdocumentation65%65% -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/css/highlight.css: -------------------------------------------------------------------------------- 1 | /* Credit to https://gist.github.com/wataru420/2048287 */ 2 | .highlight { 3 | /* Comment */ 4 | /* Error */ 5 | /* Keyword */ 6 | /* Operator */ 7 | /* Comment.Multiline */ 8 | /* Comment.Preproc */ 9 | /* Comment.Single */ 10 | /* Comment.Special */ 11 | /* Generic.Deleted */ 12 | /* Generic.Deleted.Specific */ 13 | /* Generic.Emph */ 14 | /* Generic.Error */ 15 | /* Generic.Heading */ 16 | /* Generic.Inserted */ 17 | /* Generic.Inserted.Specific */ 18 | /* Generic.Output */ 19 | /* Generic.Prompt */ 20 | /* Generic.Strong */ 21 | /* Generic.Subheading */ 22 | /* Generic.Traceback */ 23 | /* Keyword.Constant */ 24 | /* Keyword.Declaration */ 25 | /* Keyword.Pseudo */ 26 | /* Keyword.Reserved */ 27 | /* Keyword.Type */ 28 | /* Literal.Number */ 29 | /* Literal.String */ 30 | /* Name.Attribute */ 31 | /* Name.Builtin */ 32 | /* Name.Class */ 33 | /* Name.Constant */ 34 | /* Name.Entity */ 35 | /* Name.Exception */ 36 | /* Name.Function */ 37 | /* Name.Namespace */ 38 | /* Name.Tag */ 39 | /* Name.Variable */ 40 | /* Operator.Word */ 41 | /* Text.Whitespace */ 42 | /* Literal.Number.Float */ 43 | /* Literal.Number.Hex */ 44 | /* Literal.Number.Integer */ 45 | /* Literal.Number.Oct */ 46 | /* Literal.String.Backtick */ 47 | /* Literal.String.Char */ 48 | /* Literal.String.Doc */ 49 | /* Literal.String.Double */ 50 | /* Literal.String.Escape */ 51 | /* Literal.String.Heredoc */ 52 | /* Literal.String.Interpol */ 53 | /* Literal.String.Other */ 54 | /* Literal.String.Regex */ 55 | /* Literal.String.Single */ 56 | /* Literal.String.Symbol */ 57 | /* Name.Builtin.Pseudo */ 58 | /* Name.Variable.Class */ 59 | /* Name.Variable.Global */ 60 | /* Name.Variable.Instance */ 61 | /* Literal.Number.Integer.Long */ } 62 | .highlight .c { 63 | color: #999988; 64 | font-style: italic; } 65 | .highlight .err { 66 | color: #a61717; 67 | background-color: #e3d2d2; } 68 | .highlight .k { 69 | color: #000000; 70 | font-weight: bold; } 71 | .highlight .o { 72 | color: #000000; 73 | font-weight: bold; } 74 | .highlight .cm { 75 | color: #999988; 76 | font-style: italic; } 77 | .highlight .cp { 78 | color: #999999; 79 | font-weight: bold; } 80 | .highlight .c1 { 81 | color: #999988; 82 | font-style: italic; } 83 | .highlight .cs { 84 | color: #999999; 85 | font-weight: bold; 86 | font-style: italic; } 87 | .highlight .gd { 88 | color: #000000; 89 | background-color: #ffdddd; } 90 | .highlight .gd .x { 91 | color: #000000; 92 | background-color: #ffaaaa; } 93 | .highlight .ge { 94 | color: #000000; 95 | font-style: italic; } 96 | .highlight .gr { 97 | color: #aa0000; } 98 | .highlight .gh { 99 | color: #999999; } 100 | .highlight .gi { 101 | color: #000000; 102 | background-color: #ddffdd; } 103 | .highlight .gi .x { 104 | color: #000000; 105 | background-color: #aaffaa; } 106 | .highlight .go { 107 | color: #888888; } 108 | .highlight .gp { 109 | color: #555555; } 110 | .highlight .gs { 111 | font-weight: bold; } 112 | .highlight .gu { 113 | color: #aaaaaa; } 114 | .highlight .gt { 115 | color: #aa0000; } 116 | .highlight .kc { 117 | color: #000000; 118 | font-weight: bold; } 119 | .highlight .kd { 120 | color: #000000; 121 | font-weight: bold; } 122 | .highlight .kp { 123 | color: #000000; 124 | font-weight: bold; } 125 | .highlight .kr { 126 | color: #000000; 127 | font-weight: bold; } 128 | .highlight .kt { 129 | color: #445588; } 130 | .highlight .m { 131 | color: #009999; } 132 | .highlight .s { 133 | color: #d14; } 134 | .highlight .na { 135 | color: #008080; } 136 | .highlight .nb { 137 | color: #0086B3; } 138 | .highlight .nc { 139 | color: #445588; 140 | font-weight: bold; } 141 | .highlight .no { 142 | color: #008080; } 143 | .highlight .ni { 144 | color: #800080; } 145 | .highlight .ne { 146 | color: #990000; 147 | font-weight: bold; } 148 | .highlight .nf { 149 | color: #990000; } 150 | .highlight .nn { 151 | color: #555555; } 152 | .highlight .nt { 153 | color: #000080; } 154 | .highlight .nv { 155 | color: #008080; } 156 | .highlight .ow { 157 | color: #000000; 158 | font-weight: bold; } 159 | .highlight .w { 160 | color: #bbbbbb; } 161 | .highlight .mf { 162 | color: #009999; } 163 | .highlight .mh { 164 | color: #009999; } 165 | .highlight .mi { 166 | color: #009999; } 167 | .highlight .mo { 168 | color: #009999; } 169 | .highlight .sb { 170 | color: #d14; } 171 | .highlight .sc { 172 | color: #d14; } 173 | .highlight .sd { 174 | color: #d14; } 175 | .highlight .s2 { 176 | color: #d14; } 177 | .highlight .se { 178 | color: #d14; } 179 | .highlight .sh { 180 | color: #d14; } 181 | .highlight .si { 182 | color: #d14; } 183 | .highlight .sx { 184 | color: #d14; } 185 | .highlight .sr { 186 | color: #009926; } 187 | .highlight .s1 { 188 | color: #d14; } 189 | .highlight .ss { 190 | color: #990073; } 191 | .highlight .bp { 192 | color: #999999; } 193 | .highlight .vc { 194 | color: #008080; } 195 | .highlight .vg { 196 | color: #008080; } 197 | .highlight .vi { 198 | color: #008080; } 199 | .highlight .il { 200 | color: #009999; } 201 | -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/css/jazzy.css: -------------------------------------------------------------------------------- 1 | html, body, div, span, h1, h3, h4, p, a, code, em, img, ul, li, table, tbody, tr, td { 2 | background: transparent; 3 | border: 0; 4 | margin: 0; 5 | outline: 0; 6 | padding: 0; 7 | vertical-align: baseline; } 8 | 9 | body { 10 | background-color: #f2f2f2; 11 | font-family: Helvetica, freesans, Arial, sans-serif; 12 | font-size: 14px; 13 | -webkit-font-smoothing: subpixel-antialiased; 14 | word-wrap: break-word; } 15 | 16 | h1, h2, h3 { 17 | margin-top: 0.8em; 18 | margin-bottom: 0.3em; 19 | font-weight: 100; 20 | color: black; } 21 | 22 | h1 { 23 | font-size: 2.5em; } 24 | 25 | h2 { 26 | font-size: 2em; 27 | border-bottom: 1px solid #e2e2e2; } 28 | 29 | h4 { 30 | font-size: 13px; 31 | line-height: 1.5; 32 | margin-top: 21px; } 33 | 34 | h5 { 35 | font-size: 1.1em; } 36 | 37 | h6 { 38 | font-size: 1.1em; 39 | color: #777; } 40 | 41 | .section-name { 42 | color: gray; 43 | display: block; 44 | font-family: Helvetica; 45 | font-size: 22px; 46 | font-weight: 100; 47 | margin-bottom: 15px; } 48 | 49 | pre, code { 50 | font: 0.95em Menlo, monospace; 51 | color: #777; 52 | word-wrap: normal; } 53 | 54 | p code, li code { 55 | background-color: #eee; 56 | padding: 2px 4px; 57 | border-radius: 4px; } 58 | 59 | a { 60 | color: #0088cc; 61 | text-decoration: none; } 62 | 63 | ul { 64 | padding-left: 15px; } 65 | 66 | li { 67 | line-height: 1.8em; } 68 | 69 | img { 70 | max-width: 100%; } 71 | 72 | blockquote { 73 | margin-left: 0; 74 | padding: 0 10px; 75 | border-left: 4px solid #ccc; } 76 | 77 | .content-wrapper { 78 | margin: 0 auto; 79 | width: 980px; } 80 | 81 | header { 82 | font-size: 0.85em; 83 | line-height: 26px; 84 | background-color: #414141; 85 | position: fixed; 86 | width: 100%; 87 | z-index: 1; } 88 | header img { 89 | padding-right: 6px; 90 | vertical-align: -4px; 91 | height: 16px; } 92 | header a { 93 | color: #fff; } 94 | header p { 95 | float: left; 96 | color: #999; } 97 | header .header-right { 98 | float: right; 99 | margin-left: 16px; } 100 | 101 | #breadcrumbs { 102 | background-color: #f2f2f2; 103 | height: 27px; 104 | padding-top: 17px; 105 | position: fixed; 106 | width: 100%; 107 | z-index: 1; 108 | margin-top: 26px; } 109 | #breadcrumbs #carat { 110 | height: 10px; 111 | margin: 0 5px; } 112 | 113 | .sidebar { 114 | background-color: #f9f9f9; 115 | border: 1px solid #e2e2e2; 116 | overflow-y: auto; 117 | overflow-x: hidden; 118 | position: fixed; 119 | top: 70px; 120 | bottom: 0; 121 | width: 230px; 122 | word-wrap: normal; } 123 | 124 | .nav-groups { 125 | list-style-type: none; 126 | background: #fff; 127 | padding-left: 0; } 128 | 129 | .nav-group-name { 130 | border-bottom: 1px solid #e2e2e2; 131 | font-size: 1.1em; 132 | font-weight: 100; 133 | padding: 15px 0 15px 20px; } 134 | .nav-group-name > a { 135 | color: #333; } 136 | 137 | .nav-group-tasks { 138 | margin-top: 5px; } 139 | 140 | .nav-group-task { 141 | font-size: 0.9em; 142 | list-style-type: none; 143 | white-space: nowrap; } 144 | .nav-group-task a { 145 | color: #888; } 146 | 147 | .main-content { 148 | background-color: #fff; 149 | border: 1px solid #e2e2e2; 150 | margin-left: 246px; 151 | position: absolute; 152 | overflow: hidden; 153 | padding-bottom: 60px; 154 | top: 70px; 155 | width: 734px; } 156 | .main-content p, .main-content a, .main-content code, .main-content em, .main-content ul, .main-content table, .main-content blockquote { 157 | margin-bottom: 1em; } 158 | .main-content p { 159 | line-height: 1.8em; } 160 | .main-content section .section:first-child { 161 | margin-top: 0; 162 | padding-top: 0; } 163 | .main-content section .task-group-section .task-group:first-of-type { 164 | padding-top: 10px; } 165 | .main-content section .task-group-section .task-group:first-of-type .section-name { 166 | padding-top: 15px; } 167 | .main-content section .heading:before { 168 | content: ""; 169 | display: block; 170 | padding-top: 70px; 171 | margin: -70px 0 0; } 172 | 173 | .section { 174 | padding: 0 25px; } 175 | 176 | .highlight { 177 | background-color: #eee; 178 | padding: 10px 12px; 179 | border: 1px solid #e2e2e2; 180 | border-radius: 4px; 181 | overflow-x: auto; } 182 | 183 | .declaration .highlight { 184 | overflow-x: initial; 185 | padding: 0 40px 40px 0; 186 | margin-bottom: -25px; 187 | background-color: transparent; 188 | border: none; } 189 | 190 | .section-name { 191 | margin: 0; 192 | margin-left: 18px; } 193 | 194 | .task-group-section { 195 | padding-left: 6px; 196 | border-top: 1px solid #e2e2e2; } 197 | 198 | .task-group { 199 | padding-top: 0px; } 200 | 201 | .task-name-container a[name]:before { 202 | content: ""; 203 | display: block; 204 | padding-top: 70px; 205 | margin: -70px 0 0; } 206 | 207 | .item { 208 | padding-top: 8px; 209 | width: 100%; 210 | list-style-type: none; } 211 | .item a[name]:before { 212 | content: ""; 213 | display: block; 214 | padding-top: 70px; 215 | margin: -70px 0 0; } 216 | .item code { 217 | background-color: transparent; 218 | padding: 0; } 219 | .item .token { 220 | padding-left: 3px; 221 | margin-left: 15px; 222 | font-size: 11.9px; } 223 | .item .declaration-note { 224 | font-size: .85em; 225 | color: gray; 226 | font-style: italic; } 227 | 228 | .pointer-container { 229 | border-bottom: 1px solid #e2e2e2; 230 | left: -23px; 231 | padding-bottom: 13px; 232 | position: relative; 233 | width: 110%; } 234 | 235 | .pointer { 236 | background: #f9f9f9; 237 | border-left: 1px solid #e2e2e2; 238 | border-top: 1px solid #e2e2e2; 239 | height: 12px; 240 | left: 21px; 241 | top: -7px; 242 | -webkit-transform: rotate(45deg); 243 | -moz-transform: rotate(45deg); 244 | -o-transform: rotate(45deg); 245 | transform: rotate(45deg); 246 | position: absolute; 247 | width: 12px; } 248 | 249 | .height-container { 250 | display: none; 251 | left: -25px; 252 | padding: 0 25px; 253 | position: relative; 254 | width: 100%; 255 | overflow: hidden; } 256 | .height-container .section { 257 | background: #f9f9f9; 258 | border-bottom: 1px solid #e2e2e2; 259 | left: -25px; 260 | position: relative; 261 | width: 100%; 262 | padding-top: 10px; 263 | padding-bottom: 5px; } 264 | 265 | .aside, .language { 266 | padding: 6px 12px; 267 | margin: 12px 0; 268 | border-left: 5px solid #dddddd; 269 | overflow-y: hidden; } 270 | .aside .aside-title, .language .aside-title { 271 | font-size: 9px; 272 | letter-spacing: 2px; 273 | text-transform: uppercase; 274 | padding-bottom: 0; 275 | margin: 0; 276 | color: #aaa; 277 | -webkit-user-select: none; } 278 | .aside p:last-child, .language p:last-child { 279 | margin-bottom: 0; } 280 | 281 | .language { 282 | border-left: 5px solid #cde9f4; } 283 | .language .aside-title { 284 | color: #4b8afb; } 285 | 286 | .aside-warning { 287 | border-left: 5px solid #ff6666; } 288 | .aside-warning .aside-title { 289 | color: #ff0000; } 290 | 291 | .graybox { 292 | border-collapse: collapse; 293 | width: 100%; } 294 | .graybox p { 295 | margin: 0; 296 | word-break: break-word; 297 | min-width: 50px; } 298 | .graybox td { 299 | border: 1px solid #e2e2e2; 300 | padding: 5px 25px 5px 10px; 301 | vertical-align: middle; } 302 | .graybox tr td:first-of-type { 303 | text-align: right; 304 | padding: 7px; 305 | vertical-align: top; 306 | word-break: normal; 307 | width: 40px; } 308 | 309 | .slightly-smaller { 310 | font-size: 0.9em; } 311 | 312 | #footer { 313 | position: absolute; 314 | bottom: 10px; 315 | margin-left: 25px; } 316 | #footer p { 317 | margin: 0; 318 | color: #aaa; 319 | font-size: 0.8em; } 320 | 321 | html.dash header, html.dash #breadcrumbs, html.dash .sidebar { 322 | display: none; } 323 | html.dash .main-content { 324 | width: 980px; 325 | margin-left: 0; 326 | border: none; 327 | width: 100%; 328 | top: 0; 329 | padding-bottom: 0; } 330 | html.dash .height-container { 331 | display: block; } 332 | html.dash .item .token { 333 | margin-left: 0; } 334 | html.dash .content-wrapper { 335 | width: auto; } 336 | html.dash #footer { 337 | position: static; } 338 | -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/img/carat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csujedihy/SwiftDSSocket/2a6b46c77d4bc7fee53fd0a16bfd7d4f96e7428e/docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/img/carat.png -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/img/dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csujedihy/SwiftDSSocket/2a6b46c77d4bc7fee53fd0a16bfd7d4f96e7428e/docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/img/dash.png -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/img/gh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csujedihy/SwiftDSSocket/2a6b46c77d4bc7fee53fd0a16bfd7d4f96e7428e/docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/img/gh.png -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SwiftDSSocket Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |

SwiftDSSocket Docs (64% documented)

17 |
18 |
19 |
20 | 25 |
26 |
27 | 53 |
54 |
55 |
56 | 57 |

Travis-CI 58 | macOS 59 | iOS 60 | Swift Version 61 | CocoaPods 62 | Carthage Compatible 63 | SwiftPM Compatible

64 |

SwiftDSSocket

65 |

Overview

66 | 67 |

SwiftDSSocket is a purely swift based asynchronous socket framework built atop DispatchSource. Function signatures are pretty much similar to those in CocoaAsyncSocket because I implemented this framework by learning the source code of CocoaAsyncSocket. The initial idea to build this farmework is driven by the need of network library to communicate with KEXT (NKE) to re-write my Proximac project but none of frameworks I found in github supports that. Thus, I decided to implemented my own framework to do so.

68 | 69 |

Note: This framework is still under active development. It only passes my unit tests and might have various bugs.

70 |

Features

71 |

Full Delegate Support

72 | 73 |
    74 |
  • every operation invokes a call to your delagate method.
  • 75 |
76 |

IPv6 Support

77 | 78 |
    79 |
  • listens only on IPv6 protocol but accepts both IPv4 and IPv6 incoming connections.
  • 80 |
  • conforms to Apple’s new App Store restriction on IPv6 only environment with NAT64/DNS64.
  • 81 |
82 |

DNS Enabled

83 | 84 |
    85 |
  • takes advantage of sythesized IPv6 address introduced in iOS 9 and OS X 10.11 for better IPv6 support.
  • 86 |
  • uses GCD to do DNS concurrently and connect to the first reachable address.
  • 87 |
88 |

KEXT Bi-directional Interaction

89 | 90 |
    91 |
  • takes a bundle ID to interact with your KEXT like TCP stream.
  • 92 |
93 |

Using SwiftDSSocket

94 |

Including in your project

95 |

Swift Package Manager

96 | 97 |

To include SwiftDSSocket into a Swift Package Manager package, add it to the dependencies attribute defined in your Package.swift file. For example:

98 |
    dependencies: [
 99 |         .Package(url: "https://github.com/csujedihy/SwiftDSSocket", "x.x.x")
100 |     ]
101 | 
102 |

CocoaPods

103 | 104 |

To include SwiftDSSocket in a project using CocoaPods, you just add SwiftDSSocket to your Podfile, for example:

105 |
    target 'MyApp' do
106 |         use_frameworks!
107 |         pod 'SwiftDSSocket'
108 |     end
109 | 
110 |

Carthage

111 | 112 |

To include SwiftDSSocket in a project using Carthage, add a line to your Cartfile with the GitHub organization and project names and version. For example:

113 |
    github "csujedihy/SwiftDSSocket"
114 | 
115 |

Documentation

116 | 117 |

https://csujedihy.github.io/SwiftDSSocket/

118 |

Example:

119 | 120 |

The following example creates a default SwiftDSSocket instance and then immediately starts listening on port 9999 and echoes back everything sent to this server.

121 | 122 |

You can simply use telnet 127.0.0.1 9999 to connect to this server and send whatever you want.

123 |
import Cocoa
124 | import SwiftDSSocket
125 | 
126 | class ViewController: NSViewController {
127 |   var server: SwiftDSSocket?
128 |   var newClient: SwiftDSSocket?
129 |   let ServerTag = 0
130 | 
131 |   override func viewDidLoad() {
132 |     super.viewDidLoad()
133 |     server = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp)
134 |     try? server?.accept(onPort: 9999)
135 |   }
136 | }
137 | 
138 | 
139 | extension ViewController: SwiftDSSocketDelegate {
140 |   func socket(sock: SwiftDSSocket, didAcceptNewSocket newSocket: SwiftDSSocket) {
141 |     newClient = newSocket
142 |     newSocket.readData(tag: ServerTag)
143 |   }
144 | 
145 |   func socket(sock: SwiftDSSocket, didRead data: Data, tag: Int) {
146 |     sock.write(data: data, tag: ServerTag)
147 |     sock.readData(tag: ServerTag)
148 |   }
149 | }
150 | 
151 | 
152 | 153 |

Tips: Check out Demo folder to see more examples for different environments.

154 | 155 |
156 |
157 | 161 |
162 |
163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/js/jazzy.js: -------------------------------------------------------------------------------- 1 | window.jazzy = {'docset': false} 2 | if (typeof window.dash != 'undefined') { 3 | document.documentElement.className += ' dash' 4 | window.jazzy.docset = true 5 | } 6 | if (navigator.userAgent.match(/xcode/i)) { 7 | document.documentElement.className += ' xcode' 8 | window.jazzy.docset = true 9 | } 10 | 11 | // On doc load, toggle the URL hash discussion if present 12 | $(document).ready(function() { 13 | if (!window.jazzy.docset) { 14 | var linkToHash = $('a[href="' + window.location.hash +'"]'); 15 | linkToHash.trigger("click"); 16 | } 17 | }); 18 | 19 | // On token click, toggle its discussion and animate token.marginLeft 20 | $(".token").click(function(event) { 21 | if (window.jazzy.docset) { 22 | return; 23 | } 24 | var link = $(this); 25 | var animationDuration = 300; 26 | var tokenOffset = "15px"; 27 | var original = link.css('marginLeft') == tokenOffset; 28 | link.animate({'margin-left':original ? "0px" : tokenOffset}, animationDuration); 29 | $content = link.parent().parent().next(); 30 | $content.slideToggle(animationDuration); 31 | 32 | // Keeps the document from jumping to the hash. 33 | var href = $(this).attr('href'); 34 | if (history.pushState) { 35 | history.pushState({}, '', href); 36 | } else { 37 | location.hash = href; 38 | } 39 | event.preventDefault(); 40 | }); 41 | 42 | // Dumb down quotes within code blocks that delimit strings instead of quotations 43 | // https://github.com/realm/jazzy/issues/714 44 | $("code q").replaceWith(function () { 45 | return ["\"", $(this).contents(), "\""]; 46 | }); 47 | -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/search.json: -------------------------------------------------------------------------------- 1 | {"Protocols/SwiftDSSocketDelegate.html#/s:FP13SwiftDSSocket21SwiftDSSocketDelegate6socketFT4sockCS_13SwiftDSSocket7didReadV10Foundation4Data3tagSi_T_":{"name":"socket(sock:didRead:tag:)","abstract":"

delegate method called after reading data from socket

","parent_name":"SwiftDSSocketDelegate"},"Protocols/SwiftDSSocketDelegate.html#/s:FP13SwiftDSSocket21SwiftDSSocketDelegate6socketFT4sockCS_13SwiftDSSocket14didPartialReadSi3tagSi_T_":{"name":"socket(sock:didPartialRead:tag:)","abstract":"

delegate method called after reading partial data for specified data length from socket","parent_name":"SwiftDSSocketDelegate"},"Protocols/SwiftDSSocketDelegate.html#/s:FP13SwiftDSSocket21SwiftDSSocketDelegate6socketFT4sockCS_13SwiftDSSocket8didWriteSi_T_":{"name":"socket(sock:didWrite:)","abstract":"

delegate method called after reading data from socket

","parent_name":"SwiftDSSocketDelegate"},"Protocols/SwiftDSSocketDelegate.html#/s:FP13SwiftDSSocket21SwiftDSSocketDelegate6socketFT4sockCS_13SwiftDSSocket15didPartialWriteSi3tagSi_T_":{"name":"socket(sock:didPartialWrite:tag:)","abstract":"

delegate method called after writing partial data for specified data length to socket","parent_name":"SwiftDSSocketDelegate"},"Protocols/SwiftDSSocketDelegate.html#/s:FP13SwiftDSSocket21SwiftDSSocketDelegate6socketFT4sockCS_13SwiftDSSocket18didCloseConnectionGSqCS1_11SocketError__T_":{"name":"socket(sock:didCloseConnection:)","abstract":"

delegate method called after closing connection

","parent_name":"SwiftDSSocketDelegate"},"Protocols/SwiftDSSocketDelegate.html#/s:FP13SwiftDSSocket21SwiftDSSocketDelegate6socketFT4sockCS_13SwiftDSSocket16didConnectToHostSS4portVs6UInt16_T_":{"name":"socket(sock:didConnectToHost:port:)","abstract":"

delegate method called after the connection to destination is established

","parent_name":"SwiftDSSocketDelegate"},"Protocols/SwiftDSSocketDelegate.html#/s:FP13SwiftDSSocket21SwiftDSSocketDelegate6socketFT4sockCS_13SwiftDSSocket18didAcceptNewSocketS1__T_":{"name":"socket(sock:didAcceptNewSocket:)","abstract":"

delegate method called after an incoming connection is accepted

","parent_name":"SwiftDSSocketDelegate"},"Protocols/SwiftDSSocketDelegate.html":{"name":"SwiftDSSocketDelegate","abstract":"

delegate methods for each operation

"},"Classes/SwiftDSSocket/SocketType.html#/s:FOC13SwiftDSSocket13SwiftDSSocket10SocketType3tcpFMS1_S1_":{"name":"tcp","abstract":"

Undocumented

","parent_name":"SocketType"},"Classes/SwiftDSSocket/SocketType.html#/s:FOC13SwiftDSSocket13SwiftDSSocket10SocketType6kernelFMS1_S1_":{"name":"kernel","abstract":"

Undocumented

","parent_name":"SocketType"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind16socketErrorFCNTLFMS2_S2_":{"name":"socketErrorFCNTL","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind18socketErrorDefaultFMS2_S2_":{"name":"socketErrorDefault","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind16socketErrorIOCTLFMS2_S2_":{"name":"socketErrorIOCTL","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind23socketErrorWrongAddressFMS2_S2_":{"name":"socketErrorWrongAddress","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind27socketErrorAlreadyConnectedFMS2_S2_":{"name":"socketErrorAlreadyConnected","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind32socketErrorIncorrectSocketStatusFMS2_S2_":{"name":"socketErrorIncorrectSocketStatus","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind21socketErrorConnectingFMS2_S2_":{"name":"socketErrorConnecting","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind20socketErrorListeningFMS2_S2_":{"name":"socketErrorListening","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind23socketErrorReadSpecificFMS2_S2_":{"name":"socketErrorReadSpecific","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind24socketErrorWriteSpecificFMS2_S2_":{"name":"socketErrorWriteSpecific","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind21socketErrorSetSockOptFMS2_S2_":{"name":"socketErrorSetSockOpt","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind24socketErrorMallocFailureFMS2_S2_":{"name":"socketErrorMallocFailure","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html":{"name":"ErrorKind","abstract":"

Kinds of Error in SocketError

","parent_name":"SocketError"},"Classes/SwiftDSSocket/SocketError.html#/s:vCC13SwiftDSSocket13SwiftDSSocket11SocketError9errorKindGSqOS1_9ErrorKind_":{"name":"errorKind","abstract":"

specifies error kind

","parent_name":"SocketError"},"Classes/SwiftDSSocket/SocketError.html#/s:vCC13SwiftDSSocket13SwiftDSSocket11SocketError15socketErrorCodeVs5Int32":{"name":"socketErrorCode","abstract":"

specifies error code (only for BSD socket standard error code)

","parent_name":"SocketError"},"Classes/SwiftDSSocket/SocketError.html#/s:vCC13SwiftDSSocket13SwiftDSSocket11SocketError20localizedDescriptionGSqSS_":{"name":"localizedDescription","abstract":"

a description string for this error

","parent_name":"SocketError"},"Classes/SwiftDSSocket.html#/s:vC13SwiftDSSocket13SwiftDSSocket8userDataGSqP__":{"name":"userData","abstract":"

store user data that can be used for context

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:ZvC13SwiftDSSocket13SwiftDSSocket9debugModeSb":{"name":"debugMode","abstract":"

debug option (might be deprecated in future)

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket/SocketError.html":{"name":"SocketError","abstract":"

this defines all kinds of error in SwiftDSSocket

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket/SocketType.html":{"name":"SocketType","abstract":"

Socket Type

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocketcFT8delegateGSqPS_21SwiftDSSocketDelegate__13delegateQueueGSqCSo13DispatchQueue_4typeOS0_10SocketType_S0_":{"name":"init(delegate:delegateQueue:type:)","abstract":"

create a new SwiftDSSocket instance by specifying delegate, delegate queue and socket type

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket10preferIPv4FT_T_":{"name":"preferIPv4()","abstract":"

let SwiftDSSocket connect to IPv4 in priority

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket6acceptFzT6onPortVs6UInt16_T_":{"name":"accept(onPort:)","abstract":"

listen on a specified port for both IPv4/IPv6

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket7connectFzT6toHostSS4portVs6UInt16_T_":{"name":"connect(toHost:port:)","abstract":"

connect to a host using address:port

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket7connectFzT12tobundleNameSS_T_":{"name":"connect(tobundleName:)","abstract":"

Undocumented

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket5writeFT4dataV10Foundation4Data3tagSi_T_":{"name":"write(data:tag:)","abstract":"

write data to socket

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket8readDataFT3tagSi_T_":{"name":"readData(tag:)","abstract":"

read data from socket without given data length

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket8readDataFT8toLengthSu3tagSi_T_":{"name":"readData(toLength:tag:)","abstract":"

read specified length of data from socket","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket8readDataFT8toLengthSu6bufferGSpVs5UInt8_6offsetSi3tagSi_T_":{"name":"readData(toLength:buffer:offset:tag:)","abstract":"

read specified length of data into buffer that starts from offset

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket22disconnectAfterReadingFT_T_":{"name":"disconnectAfterReading()","abstract":"

disconnect socket after all read opreations queued up and prevents new read operations

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket22disconnectAfterWritingFT_T_":{"name":"disconnectAfterWriting()","abstract":"

disconnect socket after all write opreations queued up and prevents new write operations

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket32disconnectAfterReadingAndWritingFT_T_":{"name":"disconnectAfterReadingAndWriting()","abstract":"

disconnect socket after all opreations queued up and prevents new operations

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket10disconnectFT_T_":{"name":"disconnect()","abstract":"

simply disconnect socket and discards all opreations queued up

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html":{"name":"SwiftDSSocket","abstract":"

SwiftDSSocket class definition

"},"Classes.html":{"name":"Classes","abstract":"

The following classes are available globally.

"},"Protocols.html":{"name":"Protocols","abstract":"

The following protocols are available globally.

"}} -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/Documents/undocumented.json: -------------------------------------------------------------------------------- 1 | { 2 | "warnings": [ 3 | { 4 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 5 | "line": 266, 6 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorFCNTL", 7 | "symbol_kind": "source.lang.swift.decl.enumelement", 8 | "warning": "undocumented" 9 | }, 10 | { 11 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 12 | "line": 267, 13 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorDefault", 14 | "symbol_kind": "source.lang.swift.decl.enumelement", 15 | "warning": "undocumented" 16 | }, 17 | { 18 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 19 | "line": 268, 20 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorIOCTL", 21 | "symbol_kind": "source.lang.swift.decl.enumelement", 22 | "warning": "undocumented" 23 | }, 24 | { 25 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 26 | "line": 269, 27 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorWrongAddress", 28 | "symbol_kind": "source.lang.swift.decl.enumelement", 29 | "warning": "undocumented" 30 | }, 31 | { 32 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 33 | "line": 270, 34 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorAlreadyConnected", 35 | "symbol_kind": "source.lang.swift.decl.enumelement", 36 | "warning": "undocumented" 37 | }, 38 | { 39 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 40 | "line": 271, 41 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorIncorrectSocketStatus", 42 | "symbol_kind": "source.lang.swift.decl.enumelement", 43 | "warning": "undocumented" 44 | }, 45 | { 46 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 47 | "line": 272, 48 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorConnecting", 49 | "symbol_kind": "source.lang.swift.decl.enumelement", 50 | "warning": "undocumented" 51 | }, 52 | { 53 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 54 | "line": 273, 55 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorReadSpecific", 56 | "symbol_kind": "source.lang.swift.decl.enumelement", 57 | "warning": "undocumented" 58 | }, 59 | { 60 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 61 | "line": 274, 62 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorWriteSpecific", 63 | "symbol_kind": "source.lang.swift.decl.enumelement", 64 | "warning": "undocumented" 65 | }, 66 | { 67 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 68 | "line": 275, 69 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorSetSockOpt", 70 | "symbol_kind": "source.lang.swift.decl.enumelement", 71 | "warning": "undocumented" 72 | }, 73 | { 74 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 75 | "line": 276, 76 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorMallocFailure", 77 | "symbol_kind": "source.lang.swift.decl.enumelement", 78 | "warning": "undocumented" 79 | }, 80 | { 81 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 82 | "line": 298, 83 | "symbol": "SwiftDSSocket.SocketType.tcp", 84 | "symbol_kind": "source.lang.swift.decl.enumelement", 85 | "warning": "undocumented" 86 | }, 87 | { 88 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 89 | "line": 300, 90 | "symbol": "SwiftDSSocket.SocketType.kernel", 91 | "symbol_kind": "source.lang.swift.decl.enumelement", 92 | "warning": "undocumented" 93 | }, 94 | { 95 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 96 | "line": 300, 97 | "symbol": "SwiftDSSocket.SocketType.kernel", 98 | "symbol_kind": "source.lang.swift.decl.enumelement", 99 | "warning": "undocumented" 100 | }, 101 | { 102 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 103 | "line": 951, 104 | "symbol": "SwiftDSSocket.connect(tobundleName:)", 105 | "symbol_kind": "source.lang.swift.decl.function.method.instance", 106 | "warning": "undocumented" 107 | } 108 | ], 109 | "source_directory": "/Users/jedihy/Documents/Project/SwiftDSSocket" 110 | } -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.docset/Contents/Resources/docSet.dsidx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csujedihy/SwiftDSSocket/2a6b46c77d4bc7fee53fd0a16bfd7d4f96e7428e/docs/docsets/SwiftDSSocket.docset/Contents/Resources/docSet.dsidx -------------------------------------------------------------------------------- /docs/docsets/SwiftDSSocket.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csujedihy/SwiftDSSocket/2a6b46c77d4bc7fee53fd0a16bfd7d4f96e7428e/docs/docsets/SwiftDSSocket.tgz -------------------------------------------------------------------------------- /docs/img/carat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csujedihy/SwiftDSSocket/2a6b46c77d4bc7fee53fd0a16bfd7d4f96e7428e/docs/img/carat.png -------------------------------------------------------------------------------- /docs/img/dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csujedihy/SwiftDSSocket/2a6b46c77d4bc7fee53fd0a16bfd7d4f96e7428e/docs/img/dash.png -------------------------------------------------------------------------------- /docs/img/gh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csujedihy/SwiftDSSocket/2a6b46c77d4bc7fee53fd0a16bfd7d4f96e7428e/docs/img/gh.png -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SwiftDSSocket Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |

SwiftDSSocket Docs (64% documented)

17 |
18 |
19 |
20 | 25 |
26 |
27 | 53 |
54 |
55 |
56 | 57 |

Travis-CI 58 | macOS 59 | iOS 60 | Swift Version 61 | CocoaPods 62 | Carthage Compatible 63 | SwiftPM Compatible

64 |

SwiftDSSocket

65 |

Overview

66 | 67 |

SwiftDSSocket is a purely swift based asynchronous socket framework built atop DispatchSource. Function signatures are pretty much similar to those in CocoaAsyncSocket because I implemented this framework by learning the source code of CocoaAsyncSocket. The initial idea to build this farmework is driven by the need of network library to communicate with KEXT (NKE) to re-write my Proximac project but none of frameworks I found in github supports that. Thus, I decided to implemented my own framework to do so.

68 | 69 |

Note: This framework is still under active development. It only passes my unit tests and might have various bugs.

70 |

Features

71 |

Full Delegate Support

72 | 73 |
    74 |
  • every operation invokes a call to your delagate method.
  • 75 |
76 |

IPv6 Support

77 | 78 |
    79 |
  • listens only on IPv6 protocol but accepts both IPv4 and IPv6 incoming connections.
  • 80 |
  • conforms to Apple’s new App Store restriction on IPv6 only environment with NAT64/DNS64.
  • 81 |
82 |

DNS Enabled

83 | 84 |
    85 |
  • takes advantage of sythesized IPv6 address introduced in iOS 9 and OS X 10.11 for better IPv6 support.
  • 86 |
  • uses GCD to do DNS concurrently and connect to the first reachable address.
  • 87 |
88 |

KEXT Bi-directional Interaction

89 | 90 |
    91 |
  • takes a bundle ID to interact with your KEXT like TCP stream.
  • 92 |
93 |

Using SwiftDSSocket

94 |

Including in your project

95 |

Swift Package Manager

96 | 97 |

To include SwiftDSSocket into a Swift Package Manager package, add it to the dependencies attribute defined in your Package.swift file. For example:

98 |
    dependencies: [
 99 |         .Package(url: "https://github.com/csujedihy/SwiftDSSocket", "x.x.x")
100 |     ]
101 | 
102 |

CocoaPods

103 | 104 |

To include SwiftDSSocket in a project using CocoaPods, you just add SwiftDSSocket to your Podfile, for example:

105 |
    target 'MyApp' do
106 |         use_frameworks!
107 |         pod 'SwiftDSSocket'
108 |     end
109 | 
110 |

Carthage

111 | 112 |

To include SwiftDSSocket in a project using Carthage, add a line to your Cartfile with the GitHub organization and project names and version. For example:

113 |
    github "csujedihy/SwiftDSSocket"
114 | 
115 |

Documentation

116 | 117 |

https://csujedihy.github.io/SwiftDSSocket/

118 |

Example:

119 | 120 |

The following example creates a default SwiftDSSocket instance and then immediately starts listening on port 9999 and echoes back everything sent to this server.

121 | 122 |

You can simply use telnet 127.0.0.1 9999 to connect to this server and send whatever you want.

123 |
import Cocoa
124 | import SwiftDSSocket
125 | 
126 | class ViewController: NSViewController {
127 |   var server: SwiftDSSocket?
128 |   var newClient: SwiftDSSocket?
129 |   let ServerTag = 0
130 | 
131 |   override func viewDidLoad() {
132 |     super.viewDidLoad()
133 |     server = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp)
134 |     try? server?.accept(onPort: 9999)
135 |   }
136 | }
137 | 
138 | 
139 | extension ViewController: SwiftDSSocketDelegate {
140 |   func socket(sock: SwiftDSSocket, didAcceptNewSocket newSocket: SwiftDSSocket) {
141 |     newClient = newSocket
142 |     newSocket.readData(tag: ServerTag)
143 |   }
144 | 
145 |   func socket(sock: SwiftDSSocket, didRead data: Data, tag: Int) {
146 |     sock.write(data: data, tag: ServerTag)
147 |     sock.readData(tag: ServerTag)
148 |   }
149 | }
150 | 
151 | 
152 | 153 |

Tips: Check out Demo folder to see more examples for different environments.

154 | 155 |
156 |
157 | 161 |
162 |
163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /docs/js/jazzy.js: -------------------------------------------------------------------------------- 1 | window.jazzy = {'docset': false} 2 | if (typeof window.dash != 'undefined') { 3 | document.documentElement.className += ' dash' 4 | window.jazzy.docset = true 5 | } 6 | if (navigator.userAgent.match(/xcode/i)) { 7 | document.documentElement.className += ' xcode' 8 | window.jazzy.docset = true 9 | } 10 | 11 | // On doc load, toggle the URL hash discussion if present 12 | $(document).ready(function() { 13 | if (!window.jazzy.docset) { 14 | var linkToHash = $('a[href="' + window.location.hash +'"]'); 15 | linkToHash.trigger("click"); 16 | } 17 | }); 18 | 19 | // On token click, toggle its discussion and animate token.marginLeft 20 | $(".token").click(function(event) { 21 | if (window.jazzy.docset) { 22 | return; 23 | } 24 | var link = $(this); 25 | var animationDuration = 300; 26 | var tokenOffset = "15px"; 27 | var original = link.css('marginLeft') == tokenOffset; 28 | link.animate({'margin-left':original ? "0px" : tokenOffset}, animationDuration); 29 | $content = link.parent().parent().next(); 30 | $content.slideToggle(animationDuration); 31 | 32 | // Keeps the document from jumping to the hash. 33 | var href = $(this).attr('href'); 34 | if (history.pushState) { 35 | history.pushState({}, '', href); 36 | } else { 37 | location.hash = href; 38 | } 39 | event.preventDefault(); 40 | }); 41 | 42 | // Dumb down quotes within code blocks that delimit strings instead of quotations 43 | // https://github.com/realm/jazzy/issues/714 44 | $("code q").replaceWith(function () { 45 | return ["\"", $(this).contents(), "\""]; 46 | }); 47 | -------------------------------------------------------------------------------- /docs/search.json: -------------------------------------------------------------------------------- 1 | {"Protocols/SwiftDSSocketDelegate.html#/s:FP13SwiftDSSocket21SwiftDSSocketDelegate6socketFT4sockCS_13SwiftDSSocket7didReadV10Foundation4Data3tagSi_T_":{"name":"socket(sock:didRead:tag:)","abstract":"

delegate method called after reading data from socket

","parent_name":"SwiftDSSocketDelegate"},"Protocols/SwiftDSSocketDelegate.html#/s:FP13SwiftDSSocket21SwiftDSSocketDelegate6socketFT4sockCS_13SwiftDSSocket14didPartialReadSi3tagSi_T_":{"name":"socket(sock:didPartialRead:tag:)","abstract":"

delegate method called after reading partial data for specified data length from socket","parent_name":"SwiftDSSocketDelegate"},"Protocols/SwiftDSSocketDelegate.html#/s:FP13SwiftDSSocket21SwiftDSSocketDelegate6socketFT4sockCS_13SwiftDSSocket8didWriteSi_T_":{"name":"socket(sock:didWrite:)","abstract":"

delegate method called after reading data from socket

","parent_name":"SwiftDSSocketDelegate"},"Protocols/SwiftDSSocketDelegate.html#/s:FP13SwiftDSSocket21SwiftDSSocketDelegate6socketFT4sockCS_13SwiftDSSocket15didPartialWriteSi3tagSi_T_":{"name":"socket(sock:didPartialWrite:tag:)","abstract":"

delegate method called after writing partial data for specified data length to socket","parent_name":"SwiftDSSocketDelegate"},"Protocols/SwiftDSSocketDelegate.html#/s:FP13SwiftDSSocket21SwiftDSSocketDelegate6socketFT4sockCS_13SwiftDSSocket18didCloseConnectionGSqCS1_11SocketError__T_":{"name":"socket(sock:didCloseConnection:)","abstract":"

delegate method called after closing connection

","parent_name":"SwiftDSSocketDelegate"},"Protocols/SwiftDSSocketDelegate.html#/s:FP13SwiftDSSocket21SwiftDSSocketDelegate6socketFT4sockCS_13SwiftDSSocket16didConnectToHostSS4portVs6UInt16_T_":{"name":"socket(sock:didConnectToHost:port:)","abstract":"

delegate method called after the connection to destination is established

","parent_name":"SwiftDSSocketDelegate"},"Protocols/SwiftDSSocketDelegate.html#/s:FP13SwiftDSSocket21SwiftDSSocketDelegate6socketFT4sockCS_13SwiftDSSocket18didAcceptNewSocketS1__T_":{"name":"socket(sock:didAcceptNewSocket:)","abstract":"

delegate method called after an incoming connection is accepted

","parent_name":"SwiftDSSocketDelegate"},"Protocols/SwiftDSSocketDelegate.html":{"name":"SwiftDSSocketDelegate","abstract":"

delegate methods for each operation

"},"Classes/SwiftDSSocket/SocketType.html#/s:FOC13SwiftDSSocket13SwiftDSSocket10SocketType3tcpFMS1_S1_":{"name":"tcp","abstract":"

Undocumented

","parent_name":"SocketType"},"Classes/SwiftDSSocket/SocketType.html#/s:FOC13SwiftDSSocket13SwiftDSSocket10SocketType6kernelFMS1_S1_":{"name":"kernel","abstract":"

Undocumented

","parent_name":"SocketType"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind16socketErrorFCNTLFMS2_S2_":{"name":"socketErrorFCNTL","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind18socketErrorDefaultFMS2_S2_":{"name":"socketErrorDefault","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind16socketErrorIOCTLFMS2_S2_":{"name":"socketErrorIOCTL","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind23socketErrorWrongAddressFMS2_S2_":{"name":"socketErrorWrongAddress","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind27socketErrorAlreadyConnectedFMS2_S2_":{"name":"socketErrorAlreadyConnected","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind32socketErrorIncorrectSocketStatusFMS2_S2_":{"name":"socketErrorIncorrectSocketStatus","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind21socketErrorConnectingFMS2_S2_":{"name":"socketErrorConnecting","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind20socketErrorListeningFMS2_S2_":{"name":"socketErrorListening","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind23socketErrorReadSpecificFMS2_S2_":{"name":"socketErrorReadSpecific","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind24socketErrorWriteSpecificFMS2_S2_":{"name":"socketErrorWriteSpecific","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind21socketErrorSetSockOptFMS2_S2_":{"name":"socketErrorSetSockOpt","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html#/s:FOCC13SwiftDSSocket13SwiftDSSocket11SocketError9ErrorKind24socketErrorMallocFailureFMS2_S2_":{"name":"socketErrorMallocFailure","abstract":"

Undocumented

","parent_name":"ErrorKind"},"Classes/SwiftDSSocket/SocketError/ErrorKind.html":{"name":"ErrorKind","abstract":"

Kinds of Error in SocketError

","parent_name":"SocketError"},"Classes/SwiftDSSocket/SocketError.html#/s:vCC13SwiftDSSocket13SwiftDSSocket11SocketError9errorKindGSqOS1_9ErrorKind_":{"name":"errorKind","abstract":"

specifies error kind

","parent_name":"SocketError"},"Classes/SwiftDSSocket/SocketError.html#/s:vCC13SwiftDSSocket13SwiftDSSocket11SocketError15socketErrorCodeVs5Int32":{"name":"socketErrorCode","abstract":"

specifies error code (only for BSD socket standard error code)

","parent_name":"SocketError"},"Classes/SwiftDSSocket/SocketError.html#/s:vCC13SwiftDSSocket13SwiftDSSocket11SocketError20localizedDescriptionGSqSS_":{"name":"localizedDescription","abstract":"

a description string for this error

","parent_name":"SocketError"},"Classes/SwiftDSSocket.html#/s:vC13SwiftDSSocket13SwiftDSSocket8userDataGSqP__":{"name":"userData","abstract":"

store user data that can be used for context

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:ZvC13SwiftDSSocket13SwiftDSSocket9debugModeSb":{"name":"debugMode","abstract":"

debug option (might be deprecated in future)

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket/SocketError.html":{"name":"SocketError","abstract":"

this defines all kinds of error in SwiftDSSocket

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket/SocketType.html":{"name":"SocketType","abstract":"

Socket Type

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocketcFT8delegateGSqPS_21SwiftDSSocketDelegate__13delegateQueueGSqCSo13DispatchQueue_4typeOS0_10SocketType_S0_":{"name":"init(delegate:delegateQueue:type:)","abstract":"

create a new SwiftDSSocket instance by specifying delegate, delegate queue and socket type

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket10preferIPv4FT_T_":{"name":"preferIPv4()","abstract":"

let SwiftDSSocket connect to IPv4 in priority

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket6acceptFzT6onPortVs6UInt16_T_":{"name":"accept(onPort:)","abstract":"

listen on a specified port for both IPv4/IPv6

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket7connectFzT6toHostSS4portVs6UInt16_T_":{"name":"connect(toHost:port:)","abstract":"

connect to a host using address:port

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket7connectFzT12tobundleNameSS_T_":{"name":"connect(tobundleName:)","abstract":"

Undocumented

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket5writeFT4dataV10Foundation4Data3tagSi_T_":{"name":"write(data:tag:)","abstract":"

write data to socket

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket8readDataFT3tagSi_T_":{"name":"readData(tag:)","abstract":"

read data from socket without given data length

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket8readDataFT8toLengthSu3tagSi_T_":{"name":"readData(toLength:tag:)","abstract":"

read specified length of data from socket","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket8readDataFT8toLengthSu6bufferGSpVs5UInt8_6offsetSi3tagSi_T_":{"name":"readData(toLength:buffer:offset:tag:)","abstract":"

read specified length of data into buffer that starts from offset

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket22disconnectAfterReadingFT_T_":{"name":"disconnectAfterReading()","abstract":"

disconnect socket after all read opreations queued up and prevents new read operations

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket22disconnectAfterWritingFT_T_":{"name":"disconnectAfterWriting()","abstract":"

disconnect socket after all write opreations queued up and prevents new write operations

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket32disconnectAfterReadingAndWritingFT_T_":{"name":"disconnectAfterReadingAndWriting()","abstract":"

disconnect socket after all opreations queued up and prevents new operations

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html#/s:FC13SwiftDSSocket13SwiftDSSocket10disconnectFT_T_":{"name":"disconnect()","abstract":"

simply disconnect socket and discards all opreations queued up

","parent_name":"SwiftDSSocket"},"Classes/SwiftDSSocket.html":{"name":"SwiftDSSocket","abstract":"

SwiftDSSocket class definition

"},"Classes.html":{"name":"Classes","abstract":"

The following classes are available globally.

"},"Protocols.html":{"name":"Protocols","abstract":"

The following protocols are available globally.

"}} -------------------------------------------------------------------------------- /docs/undocumented.json: -------------------------------------------------------------------------------- 1 | { 2 | "warnings": [ 3 | { 4 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 5 | "line": 266, 6 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorFCNTL", 7 | "symbol_kind": "source.lang.swift.decl.enumelement", 8 | "warning": "undocumented" 9 | }, 10 | { 11 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 12 | "line": 267, 13 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorDefault", 14 | "symbol_kind": "source.lang.swift.decl.enumelement", 15 | "warning": "undocumented" 16 | }, 17 | { 18 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 19 | "line": 268, 20 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorIOCTL", 21 | "symbol_kind": "source.lang.swift.decl.enumelement", 22 | "warning": "undocumented" 23 | }, 24 | { 25 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 26 | "line": 269, 27 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorWrongAddress", 28 | "symbol_kind": "source.lang.swift.decl.enumelement", 29 | "warning": "undocumented" 30 | }, 31 | { 32 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 33 | "line": 270, 34 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorAlreadyConnected", 35 | "symbol_kind": "source.lang.swift.decl.enumelement", 36 | "warning": "undocumented" 37 | }, 38 | { 39 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 40 | "line": 271, 41 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorIncorrectSocketStatus", 42 | "symbol_kind": "source.lang.swift.decl.enumelement", 43 | "warning": "undocumented" 44 | }, 45 | { 46 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 47 | "line": 272, 48 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorConnecting", 49 | "symbol_kind": "source.lang.swift.decl.enumelement", 50 | "warning": "undocumented" 51 | }, 52 | { 53 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 54 | "line": 273, 55 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorListening", 56 | "symbol_kind": "source.lang.swift.decl.enumelement", 57 | "warning": "undocumented" 58 | }, 59 | { 60 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 61 | "line": 274, 62 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorReadSpecific", 63 | "symbol_kind": "source.lang.swift.decl.enumelement", 64 | "warning": "undocumented" 65 | }, 66 | { 67 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 68 | "line": 275, 69 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorWriteSpecific", 70 | "symbol_kind": "source.lang.swift.decl.enumelement", 71 | "warning": "undocumented" 72 | }, 73 | { 74 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 75 | "line": 276, 76 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorSetSockOpt", 77 | "symbol_kind": "source.lang.swift.decl.enumelement", 78 | "warning": "undocumented" 79 | }, 80 | { 81 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 82 | "line": 277, 83 | "symbol": "SwiftDSSocket.SocketError.ErrorKind.socketErrorMallocFailure", 84 | "symbol_kind": "source.lang.swift.decl.enumelement", 85 | "warning": "undocumented" 86 | }, 87 | { 88 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 89 | "line": 299, 90 | "symbol": "SwiftDSSocket.SocketType.tcp", 91 | "symbol_kind": "source.lang.swift.decl.enumelement", 92 | "warning": "undocumented" 93 | }, 94 | { 95 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 96 | "line": 301, 97 | "symbol": "SwiftDSSocket.SocketType.kernel", 98 | "symbol_kind": "source.lang.swift.decl.enumelement", 99 | "warning": "undocumented" 100 | }, 101 | { 102 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 103 | "line": 301, 104 | "symbol": "SwiftDSSocket.SocketType.kernel", 105 | "symbol_kind": "source.lang.swift.decl.enumelement", 106 | "warning": "undocumented" 107 | }, 108 | { 109 | "file": "/Users/jedihy/Documents/Project/SwiftDSSocket/Sources/SwiftDSSocket.swift", 110 | "line": 954, 111 | "symbol": "SwiftDSSocket.connect(tobundleName:)", 112 | "symbol_kind": "source.lang.swift.decl.function.method.instance", 113 | "warning": "undocumented" 114 | } 115 | ], 116 | "source_directory": "/Users/jedihy/Documents/Project/SwiftDSSocket" 117 | } --------------------------------------------------------------------------------