├── CocoaAsyncSocket ├── .gitignore ├── .travis.yml ├── CocoaAsyncSocket.podspec ├── CocoaAsyncSocket.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ ├── Mac Framework.xcscheme │ │ ├── iOS Framework.xcscheme │ │ └── tvOS Framework.xcscheme ├── Examples │ ├── GCD │ │ ├── BonjourClient │ │ │ ├── BonjourClient-Info.plist │ │ │ ├── BonjourClient.xcodeproj │ │ │ │ ├── project.pbxproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ ├── BonjourClientAppDelegate.h │ │ │ ├── BonjourClientAppDelegate.m │ │ │ ├── BonjourClient_Prefix.pch │ │ │ ├── English.lproj │ │ │ │ ├── InfoPlist.strings │ │ │ │ └── MainMenu.xib │ │ │ └── main.m │ │ ├── BonjourServer │ │ │ ├── BonjourServer-Info.plist │ │ │ ├── BonjourServer.xcodeproj │ │ │ │ ├── project.pbxproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ ├── BonjourServerAppDelegate.h │ │ │ ├── BonjourServerAppDelegate.m │ │ │ ├── BonjourServer_Prefix.pch │ │ │ ├── English.lproj │ │ │ │ ├── InfoPlist.strings │ │ │ │ └── MainMenu.xib │ │ │ └── main.m │ │ ├── ConnectTest │ │ │ ├── Desktop │ │ │ │ ├── ConnectTest.xcodeproj │ │ │ │ │ ├── project.pbxproj │ │ │ │ │ └── project.xcworkspace │ │ │ │ │ │ └── contents.xcworkspacedata │ │ │ │ └── ConnectTest │ │ │ │ │ ├── ConnectTest-Info.plist │ │ │ │ │ ├── ConnectTest-Prefix.pch │ │ │ │ │ ├── ConnectTestAppDelegate.h │ │ │ │ │ ├── ConnectTestAppDelegate.m │ │ │ │ │ ├── en.lproj │ │ │ │ │ ├── Credits.rtf │ │ │ │ │ ├── InfoPlist.strings │ │ │ │ │ └── MainMenu.xib │ │ │ │ │ └── main.m │ │ │ ├── Mobile │ │ │ │ ├── ConnectTest.xcodeproj │ │ │ │ │ ├── project.pbxproj │ │ │ │ │ └── project.xcworkspace │ │ │ │ │ │ └── contents.xcworkspacedata │ │ │ │ ├── ConnectTest │ │ │ │ │ ├── ConnectTest-Info.plist │ │ │ │ │ ├── ConnectTest-Prefix.pch │ │ │ │ │ ├── ConnectTestAppDelegate.h │ │ │ │ │ ├── ConnectTestAppDelegate.m │ │ │ │ │ ├── ConnectTestViewController.h │ │ │ │ │ ├── ConnectTestViewController.m │ │ │ │ │ ├── en.lproj │ │ │ │ │ │ ├── ConnectTestViewController.xib │ │ │ │ │ │ ├── InfoPlist.strings │ │ │ │ │ │ └── MainWindow.xib │ │ │ │ │ └── main.m │ │ │ │ └── Default-568h@2x.png │ │ │ └── ReadMe.txt │ │ ├── DomainTest │ │ │ ├── DomainTest.xcodeproj │ │ │ │ ├── project.pbxproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ └── DomainTest │ │ │ │ ├── AppDelegate.h │ │ │ │ ├── AppDelegate.m │ │ │ │ ├── DomainClient.h │ │ │ │ ├── DomainClient.m │ │ │ │ ├── DomainClient.xib │ │ │ │ ├── DomainServer.h │ │ │ │ ├── DomainServer.m │ │ │ │ ├── DomainTest-Info.plist │ │ │ │ ├── DomainTest-Prefix.pch │ │ │ │ ├── en.lproj │ │ │ │ ├── Credits.rtf │ │ │ │ ├── InfoPlist.strings │ │ │ │ └── MainMenu.xib │ │ │ │ └── main.m │ │ ├── EchoServer │ │ │ ├── EchoServer-Info.plist │ │ │ ├── EchoServer.xcodeproj │ │ │ │ ├── project.pbxproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ ├── EchoServerAppDelegate.h │ │ │ ├── EchoServerAppDelegate.m │ │ │ ├── EchoServer_Prefix.pch │ │ │ ├── English.lproj │ │ │ │ ├── InfoPlist.strings │ │ │ │ └── MainMenu.xib │ │ │ └── main.m │ │ ├── SimpleHTTPClient │ │ │ ├── Desktop │ │ │ │ ├── SimpleHTTPClient.xcodeproj │ │ │ │ │ ├── project.pbxproj │ │ │ │ │ └── project.xcworkspace │ │ │ │ │ │ └── contents.xcworkspacedata │ │ │ │ └── SimpleHTTPClient │ │ │ │ │ ├── SimpleHTTPClient-Info.plist │ │ │ │ │ ├── SimpleHTTPClient-Prefix.pch │ │ │ │ │ ├── SimpleHTTPClientAppDelegate.h │ │ │ │ │ ├── SimpleHTTPClientAppDelegate.m │ │ │ │ │ ├── en.lproj │ │ │ │ │ ├── Credits.rtf │ │ │ │ │ ├── InfoPlist.strings │ │ │ │ │ └── MainMenu.xib │ │ │ │ │ └── main.m │ │ │ ├── Mobile │ │ │ │ ├── Default-568h@2x.png │ │ │ │ ├── SimpleHTTPClient.xcodeproj │ │ │ │ │ ├── project.pbxproj │ │ │ │ │ └── project.xcworkspace │ │ │ │ │ │ └── contents.xcworkspacedata │ │ │ │ └── SimpleHTTPClient │ │ │ │ │ ├── SimpleHTTPClient-Info.plist │ │ │ │ │ ├── SimpleHTTPClient-Prefix.pch │ │ │ │ │ ├── SimpleHTTPClientAppDelegate.h │ │ │ │ │ ├── SimpleHTTPClientAppDelegate.m │ │ │ │ │ ├── SimpleHTTPClientViewController.h │ │ │ │ │ ├── SimpleHTTPClientViewController.m │ │ │ │ │ ├── en.lproj │ │ │ │ │ ├── InfoPlist.strings │ │ │ │ │ ├── MainWindow.xib │ │ │ │ │ └── SimpleHTTPClientViewController.xib │ │ │ │ │ └── main.m │ │ │ └── ReadMe.txt │ │ ├── TestPreBuffer │ │ │ ├── Desktop │ │ │ │ ├── TestPreBuffer.xcodeproj │ │ │ │ │ ├── project.pbxproj │ │ │ │ │ └── project.xcworkspace │ │ │ │ │ │ └── contents.xcworkspacedata │ │ │ │ └── TestPreBuffer │ │ │ │ │ ├── AppDelegate.h │ │ │ │ │ ├── AppDelegate.m │ │ │ │ │ ├── TestPreBuffer-Info.plist │ │ │ │ │ ├── TestPreBuffer-Prefix.pch │ │ │ │ │ ├── en.lproj │ │ │ │ │ ├── Credits.rtf │ │ │ │ │ ├── InfoPlist.strings │ │ │ │ │ └── MainMenu.xib │ │ │ │ │ └── main.m │ │ │ ├── Mobile │ │ │ │ ├── Default-568h@2x.png │ │ │ │ ├── TestPreBuffer.xcodeproj │ │ │ │ │ ├── project.pbxproj │ │ │ │ │ └── project.xcworkspace │ │ │ │ │ │ └── contents.xcworkspacedata │ │ │ │ └── TestPreBuffer │ │ │ │ │ ├── AppDelegate.h │ │ │ │ │ ├── AppDelegate.m │ │ │ │ │ ├── TestPreBuffer-Info.plist │ │ │ │ │ ├── TestPreBuffer-Prefix.pch │ │ │ │ │ ├── ViewController.h │ │ │ │ │ ├── ViewController.m │ │ │ │ │ ├── en.lproj │ │ │ │ │ ├── InfoPlist.strings │ │ │ │ │ ├── ViewController_iPad.xib │ │ │ │ │ └── ViewController_iPhone.xib │ │ │ │ │ └── main.m │ │ │ └── Shared │ │ │ │ ├── TestPreBuffer.h │ │ │ │ └── TestPreBuffer.m │ │ ├── UdpEchoClient │ │ │ ├── Desktop │ │ │ │ ├── UdpEchoClient.xcodeproj │ │ │ │ │ ├── project.pbxproj │ │ │ │ │ └── project.xcworkspace │ │ │ │ │ │ └── contents.xcworkspacedata │ │ │ │ └── UdpEchoClient │ │ │ │ │ ├── AppDelegate.h │ │ │ │ │ ├── AppDelegate.m │ │ │ │ │ ├── UdpEchoClient-Info.plist │ │ │ │ │ ├── UdpEchoClient-Prefix.pch │ │ │ │ │ ├── en.lproj │ │ │ │ │ ├── Credits.rtf │ │ │ │ │ ├── InfoPlist.strings │ │ │ │ │ └── MainMenu.xib │ │ │ │ │ └── main.m │ │ │ └── Mobile │ │ │ │ ├── Default-568h@2x.png │ │ │ │ ├── UdpEchoClient.xcodeproj │ │ │ │ ├── project.pbxproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ │ └── UdpEchoClient │ │ │ │ ├── AppDelegate.h │ │ │ │ ├── AppDelegate.m │ │ │ │ ├── UdpEchoClient-Info.plist │ │ │ │ ├── UdpEchoClient-Prefix.pch │ │ │ │ ├── ViewController.h │ │ │ │ ├── ViewController.m │ │ │ │ ├── en.lproj │ │ │ │ ├── InfoPlist.strings │ │ │ │ └── ViewController.xib │ │ │ │ └── main.m │ │ └── UdpEchoServer │ │ │ ├── Desktop │ │ │ ├── UdpEchoServer.xcodeproj │ │ │ │ ├── project.pbxproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ └── UdpEchoServer │ │ │ │ ├── AppDelegate.h │ │ │ │ ├── AppDelegate.m │ │ │ │ ├── UdpEchoServer-Info.plist │ │ │ │ ├── UdpEchoServer-Prefix.pch │ │ │ │ ├── en.lproj │ │ │ │ ├── Credits.rtf │ │ │ │ ├── InfoPlist.strings │ │ │ │ └── MainMenu.xib │ │ │ │ └── main.m │ │ │ └── Mobile │ │ │ ├── UdpEchoServer.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── project.xcworkspace │ │ │ │ └── contents.xcworkspacedata │ │ │ └── UdpEchoServer │ │ │ ├── AppDelegate.h │ │ │ ├── AppDelegate.m │ │ │ ├── UdpEchoServer-Info.plist │ │ │ ├── UdpEchoServer-Prefix.pch │ │ │ ├── ViewController.h │ │ │ ├── ViewController.m │ │ │ ├── en.lproj │ │ │ ├── InfoPlist.strings │ │ │ └── ViewController.xib │ │ │ └── main.m │ └── RunLoop │ │ ├── EchoServer │ │ ├── AppController.h │ │ ├── AppController.m │ │ ├── EchoServer.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── project.xcworkspace │ │ │ │ └── contents.xcworkspacedata │ │ ├── EchoServer_Prefix.pch │ │ ├── English.lproj │ │ │ ├── InfoPlist.strings │ │ │ └── MainMenu.nib │ │ │ │ ├── designable.nib │ │ │ │ └── keyedobjects.nib │ │ ├── Info.plist │ │ ├── Instructions.txt │ │ └── main.m │ │ ├── InterfaceTest │ │ ├── Classes │ │ │ ├── InterfaceTestAppDelegate.h │ │ │ ├── InterfaceTestAppDelegate.m │ │ │ ├── InterfaceTestViewController.h │ │ │ └── InterfaceTestViewController.m │ │ ├── Default-568h@2x.png │ │ ├── InterfaceTest-Info.plist │ │ ├── InterfaceTest.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── project.xcworkspace │ │ │ │ └── contents.xcworkspacedata │ │ ├── InterfaceTestViewController.xib │ │ ├── InterfaceTest_Prefix.pch │ │ ├── MainWindow.xib │ │ ├── Readme.txt │ │ └── main.m │ │ ├── UdpEchoClient │ │ ├── UdpEchoClient.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── project.xcworkspace │ │ │ │ └── contents.xcworkspacedata │ │ └── UdpEchoClient │ │ │ ├── AppDelegate.h │ │ │ ├── AppDelegate.m │ │ │ ├── UdpEchoClient-Info.plist │ │ │ ├── UdpEchoClient-Prefix.pch │ │ │ ├── en.lproj │ │ │ ├── Credits.rtf │ │ │ ├── InfoPlist.strings │ │ │ └── MainMenu.xib │ │ │ └── main.m │ │ └── UdpEchoServer │ │ ├── UdpEchoServer.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── UdpEchoServer │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── UdpEchoServer-Info.plist │ │ ├── UdpEchoServer-Prefix.pch │ │ ├── en.lproj │ │ ├── Credits.rtf │ │ ├── InfoPlist.strings │ │ └── MainMenu.xib │ │ └── main.m ├── README.markdown ├── Source │ ├── CocoaAsyncSocket.h │ ├── GCD │ │ ├── Documentation.html │ │ ├── GCDAsyncSocket.h │ │ ├── GCDAsyncSocket.m │ │ ├── GCDAsyncUdpSocket.h │ │ └── GCDAsyncUdpSocket.m │ ├── Info.plist │ ├── RunLoop │ │ ├── AsyncSocket.h │ │ ├── AsyncSocket.m │ │ ├── AsyncUdpSocket.h │ │ ├── AsyncUdpSocket.m │ │ └── Documentation.html │ └── Vendor │ │ └── CocoaLumberjack │ │ ├── DDASLLogger.h │ │ ├── DDASLLogger.m │ │ ├── DDAbstractDatabaseLogger.h │ │ ├── DDAbstractDatabaseLogger.m │ │ ├── DDFileLogger.h │ │ ├── DDFileLogger.m │ │ ├── DDLog+LOGV.h │ │ ├── DDLog.h │ │ ├── DDLog.m │ │ ├── DDTTYLogger.h │ │ ├── DDTTYLogger.m │ │ └── Extensions │ │ ├── DDContextFilterLogFormatter.h │ │ ├── DDContextFilterLogFormatter.m │ │ ├── DDDispatchQueueLogFormatter.h │ │ ├── DDDispatchQueueLogFormatter.m │ │ ├── DDMultiFormatter.h │ │ ├── DDMultiFormatter.m │ │ └── README.txt └── Tests │ ├── CocoaAsyncSocket.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ ├── CocoaAsyncSocketTestsMac.xcscheme │ │ └── CocoaAsyncSocketTestsiOS.xcscheme │ ├── CocoaAsyncSocket.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── WorkspaceSettings.xcsettings │ ├── Mac │ ├── GCDAsyncSocketUNTests.m │ └── Info.plist │ ├── Podfile │ ├── Podfile.lock │ ├── Shared │ └── GCDAsyncSocketConnectionTests.m │ └── iOS │ └── Info.plist ├── Core ├── CameraEncoder.h ├── CameraEncoder.m ├── Codec │ ├── AACEncoder.h │ ├── AACEncoder.m │ ├── H264HWDecoder.h │ ├── H264HWDecoder.m │ ├── H264HWEncoder.h │ ├── H264HWEncoder.m │ ├── H264Packet.h │ └── H264Packet.m ├── RTP │ ├── RTPClient.h │ └── RTPClient.m └── RTSP │ ├── RTSPClient.h │ └── RTSPClient.m ├── HLSforOSX ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ └── Main.storyboard ├── CameraViewController.h ├── CameraViewController.m ├── Info.plist └── main.m ├── HTTPLiveStreaming.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── MOBIUS.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── MOBIUS.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── HLSforOSX.xcscheme │ ├── HTTPLiveStreaming.xcscheme │ └── xcschememanagement.plist ├── HTTPLiveStreaming ├── AAPLPlayerView.h ├── AAPLPlayerView.m ├── AAPLPlayerViewController.h ├── AAPLPlayerViewController.m ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── CameraViewController.h ├── CameraViewController.m ├── Info.plist ├── en.lproj │ ├── Localizable.strings │ └── Localizable.stringsdict └── main.m ├── LICENSE └── README.md /CocoaAsyncSocket/.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 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | .DS_Store 22 | *.xccheckout 23 | *.moved-aside 24 | *.xcuserstate 25 | *.xcscmblueprint 26 | 27 | ## Obj-C/Swift specific 28 | *.hmap 29 | *.ipa 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build -------------------------------------------------------------------------------- /CocoaAsyncSocket/.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode6.4 3 | 4 | before_install: 5 | - gem install cocoapods --no-rdoc --no-ri 6 | 7 | install: 8 | - pod install --project-directory=./Tests 9 | 10 | script: 11 | - xctool -workspace ./Tests/CocoaAsyncSocket.xcworkspace -scheme CocoaAsyncSocketTestsiOS -sdk iphonesimulator -arch i386 test 12 | - xctool -workspace ./Tests/CocoaAsyncSocket.xcworkspace -scheme CocoaAsyncSocketTestsMac -sdk macosx -arch x86_64 test 13 | - xctool -project CocoaAsyncSocket.xcodeproj -scheme "iOS Framework" -sdk iphonesimulator -arch i386 build 14 | - xctool -project CocoaAsyncSocket.xcodeproj -scheme "Mac Framework" -sdk macosx10.10 -arch x86_64 build -------------------------------------------------------------------------------- /CocoaAsyncSocket/CocoaAsyncSocket.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'CocoaAsyncSocket' 3 | s.version = '7.4.2' 4 | s.license = { :type => 'public domain', :text => <<-LICENSE 5 | Public Domain License 6 | 7 | The CocoaAsyncSocket project is in the public domain. 8 | 9 | The original TCP version (AsyncSocket) was created by Dustin Voss in January 2003. 10 | Updated and maintained by Deusty LLC and the Apple development community. 11 | LICENSE 12 | } 13 | s.summary = 'Asynchronous socket networking library for Mac and iOS.' 14 | s.homepage = 'https://github.com/robbiehanson/CocoaAsyncSocket' 15 | s.authors = 'Dustin Voss', { 'Robbie Hanson' => 'robbiehanson@deusty.com' } 16 | 17 | s.source = { :git => 'https://github.com/robbiehanson/CocoaAsyncSocket.git', 18 | :tag => "#{s.version}" } 19 | 20 | s.description = 'CocoaAsyncSocket supports TCP and UDP. The AsyncSocket class is for TCP, and the AsyncUdpSocket class is for UDP. ' \ 21 | 'AsyncSocket is a TCP/IP socket networking library that wraps CFSocket and CFStream. It offers asynchronous ' \ 22 | 'operation, and a native Cocoa class complete with delegate support or use the GCD variant GCDAsyncSocket. ' \ 23 | 'AsyncUdpSocket is a UDP/IP socket networking library that wraps CFSocket. It works almost exactly like the TCP ' \ 24 | 'version, but is designed specifically for UDP. This includes queued non-blocking send/receive operations, full ' \ 25 | 'delegate support, run-loop based, self-contained class, and support for IPv4 and IPv6.' 26 | 27 | s.source_files = 'Source/{GCD,RunLoop}/*.{h,m}', 'Source/CocoaAsyncSocket.h' 28 | 29 | s.requires_arc = true 30 | 31 | # dispatch_queue_set_specific() is available in OS X v10.7+ and iOS 5.0+ 32 | s.ios.deployment_target = '5.0' 33 | s.tvos.deployment_target = '9.0' 34 | s.osx.deployment_target = '10.7' 35 | 36 | s.ios.frameworks = 'CFNetwork', 'Security' 37 | s.tvos.frameworks = 'CFNetwork', 'Security' 38 | s.osx.frameworks = 'CoreServices', 'Security' 39 | end 40 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/CocoaAsyncSocket.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/CocoaAsyncSocket.xcodeproj/xcshareddata/xcschemes/Mac Framework.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | 68 | 78 | 79 | 85 | 86 | 87 | 88 | 89 | 90 | 96 | 97 | 103 | 104 | 105 | 106 | 108 | 109 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/CocoaAsyncSocket.xcodeproj/xcshareddata/xcschemes/iOS Framework.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 65 | 71 | 72 | 73 | 74 | 75 | 76 | 82 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/CocoaAsyncSocket.xcodeproj/xcshareddata/xcschemes/tvOS Framework.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/BonjourClient/BonjourClient-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/BonjourClient/BonjourClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/BonjourClient/BonjourClientAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class GCDAsyncSocket; 4 | 5 | 6 | @interface BonjourClientAppDelegate : NSObject 7 | { 8 | NSNetServiceBrowser *netServiceBrowser; 9 | NSNetService *serverService; 10 | NSMutableArray *serverAddresses; 11 | GCDAsyncSocket *asyncSocket; 12 | BOOL connected; 13 | 14 | NSWindow *__unsafe_unretained window; 15 | } 16 | 17 | @property (unsafe_unretained) IBOutlet NSWindow *window; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/BonjourClient/BonjourClientAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "BonjourClientAppDelegate.h" 2 | #import "GCDAsyncSocket.h" 3 | #import "DDLog.h" 4 | #import "DDTTYLogger.h" 5 | #import "DDASLLogger.h" 6 | 7 | // Log levels: off, error, warn, info, verbose 8 | static const int ddLogLevel = LOG_LEVEL_VERBOSE; 9 | 10 | @interface BonjourClientAppDelegate (Private) 11 | - (void)connectToNextAddress; 12 | @end 13 | 14 | #pragma mark - 15 | 16 | @implementation BonjourClientAppDelegate 17 | 18 | @synthesize window; 19 | 20 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 21 | { 22 | // Configure logging framework 23 | 24 | [DDLog addLogger:[DDTTYLogger sharedInstance]]; 25 | [DDLog addLogger:[DDASLLogger sharedInstance]]; 26 | 27 | // Start browsing for bonjour services 28 | 29 | netServiceBrowser = [[NSNetServiceBrowser alloc] init]; 30 | 31 | [netServiceBrowser setDelegate:self]; 32 | [netServiceBrowser searchForServicesOfType:@"_YourServiceName._tcp." inDomain:@"local."]; 33 | } 34 | 35 | - (void)netServiceBrowser:(NSNetServiceBrowser *)sender didNotSearch:(NSDictionary *)errorInfo 36 | { 37 | DDLogError(@"DidNotSearch: %@", errorInfo); 38 | } 39 | 40 | - (void)netServiceBrowser:(NSNetServiceBrowser *)sender 41 | didFindService:(NSNetService *)netService 42 | moreComing:(BOOL)moreServicesComing 43 | { 44 | DDLogVerbose(@"DidFindService: %@", [netService name]); 45 | 46 | // Connect to the first service we find 47 | 48 | if (serverService == nil) 49 | { 50 | DDLogVerbose(@"Resolving..."); 51 | 52 | serverService = netService; 53 | 54 | [serverService setDelegate:self]; 55 | [serverService resolveWithTimeout:5.0]; 56 | } 57 | } 58 | 59 | - (void)netServiceBrowser:(NSNetServiceBrowser *)sender 60 | didRemoveService:(NSNetService *)netService 61 | moreComing:(BOOL)moreServicesComing 62 | { 63 | DDLogVerbose(@"DidRemoveService: %@", [netService name]); 64 | } 65 | 66 | - (void)netServiceBrowserDidStopSearch:(NSNetServiceBrowser *)sender 67 | { 68 | DDLogInfo(@"DidStopSearch"); 69 | } 70 | 71 | - (void)netService:(NSNetService *)sender didNotResolve:(NSDictionary *)errorDict 72 | { 73 | DDLogError(@"DidNotResolve"); 74 | } 75 | 76 | - (void)netServiceDidResolveAddress:(NSNetService *)sender 77 | { 78 | DDLogInfo(@"DidResolve: %@", [sender addresses]); 79 | 80 | if (serverAddresses == nil) 81 | { 82 | serverAddresses = [[sender addresses] mutableCopy]; 83 | } 84 | 85 | if (asyncSocket == nil) 86 | { 87 | asyncSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()]; 88 | 89 | [self connectToNextAddress]; 90 | } 91 | } 92 | 93 | - (void)connectToNextAddress 94 | { 95 | BOOL done = NO; 96 | 97 | while (!done && ([serverAddresses count] > 0)) 98 | { 99 | NSData *addr; 100 | 101 | // Note: The serverAddresses array probably contains both IPv4 and IPv6 addresses. 102 | // 103 | // If your server is also using GCDAsyncSocket then you don't have to worry about it, 104 | // as the socket automatically handles both protocols for you transparently. 105 | 106 | if (YES) // Iterate forwards 107 | { 108 | addr = [serverAddresses objectAtIndex:0]; 109 | [serverAddresses removeObjectAtIndex:0]; 110 | } 111 | else // Iterate backwards 112 | { 113 | addr = [serverAddresses lastObject]; 114 | [serverAddresses removeLastObject]; 115 | } 116 | 117 | DDLogVerbose(@"Attempting connection to %@", addr); 118 | 119 | NSError *err = nil; 120 | if ([asyncSocket connectToAddress:addr error:&err]) 121 | { 122 | done = YES; 123 | } 124 | else 125 | { 126 | DDLogWarn(@"Unable to connect: %@", err); 127 | } 128 | 129 | } 130 | 131 | if (!done) 132 | { 133 | DDLogWarn(@"Unable to connect to any resolved address"); 134 | } 135 | } 136 | 137 | - (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port 138 | { 139 | DDLogInfo(@"Socket:DidConnectToHost: %@ Port: %hu", host, port); 140 | 141 | connected = YES; 142 | } 143 | 144 | - (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err 145 | { 146 | DDLogWarn(@"SocketDidDisconnect:WithError: %@", err); 147 | 148 | if (!connected) 149 | { 150 | [self connectToNextAddress]; 151 | } 152 | } 153 | 154 | @end 155 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/BonjourClient/BonjourClient_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'BonjourClient' target in the 'BonjourClient' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/BonjourClient/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/BonjourClient/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // BonjourClient 4 | // 5 | // Created by Robbie Hanson on 1/27/11. 6 | // Copyright 2011 Voalte. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/BonjourServer/BonjourServer-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/BonjourServer/BonjourServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/BonjourServer/BonjourServerAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class GCDAsyncSocket; 4 | 5 | 6 | @interface BonjourServerAppDelegate : NSObject 7 | { 8 | NSNetService *netService; 9 | GCDAsyncSocket *asyncSocket; 10 | NSMutableArray *connectedSockets; 11 | 12 | NSWindow *__unsafe_unretained window; 13 | } 14 | 15 | @property (unsafe_unretained) IBOutlet NSWindow *window; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/BonjourServer/BonjourServerAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "BonjourServerAppDelegate.h" 2 | #import "GCDAsyncSocket.h" 3 | #import "DDLog.h" 4 | #import "DDTTYLogger.h" 5 | #import "DDASLLogger.h" 6 | 7 | // Log levels: off, error, warn, info, verbose 8 | static const int ddLogLevel = LOG_LEVEL_VERBOSE; 9 | 10 | 11 | @implementation BonjourServerAppDelegate 12 | 13 | @synthesize window; 14 | 15 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 16 | { 17 | // Configure logging framework 18 | 19 | [DDLog addLogger:[DDTTYLogger sharedInstance]]; 20 | [DDLog addLogger:[DDASLLogger sharedInstance]]; 21 | 22 | // Create our socket. 23 | // We tell it to invoke our delegate methods on the main thread. 24 | 25 | asyncSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()]; 26 | 27 | // Create an array to hold accepted incoming connections. 28 | 29 | connectedSockets = [[NSMutableArray alloc] init]; 30 | 31 | // Now we tell the socket to accept incoming connections. 32 | // We don't care what port it listens on, so we pass zero for the port number. 33 | // This allows the operating system to automatically assign us an available port. 34 | 35 | NSError *err = nil; 36 | if ([asyncSocket acceptOnPort:0 error:&err]) 37 | { 38 | // So what port did the OS give us? 39 | 40 | UInt16 port = [asyncSocket localPort]; 41 | 42 | // Create and publish the bonjour service. 43 | // Obviously you will be using your own custom service type. 44 | 45 | netService = [[NSNetService alloc] initWithDomain:@"local." 46 | type:@"_YourServiceName._tcp." 47 | name:@"" 48 | port:port]; 49 | 50 | [netService setDelegate:self]; 51 | [netService publish]; 52 | 53 | // You can optionally add TXT record stuff 54 | 55 | NSMutableDictionary *txtDict = [NSMutableDictionary dictionaryWithCapacity:2]; 56 | 57 | [txtDict setObject:@"moo" forKey:@"cow"]; 58 | [txtDict setObject:@"quack" forKey:@"duck"]; 59 | 60 | NSData *txtData = [NSNetService dataFromTXTRecordDictionary:txtDict]; 61 | [netService setTXTRecordData:txtData]; 62 | } 63 | else 64 | { 65 | DDLogError(@"Error in acceptOnPort:error: -> %@", err); 66 | } 67 | } 68 | 69 | - (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket 70 | { 71 | DDLogInfo(@"Accepted new socket from %@:%hu", [newSocket connectedHost], [newSocket connectedPort]); 72 | 73 | // The newSocket automatically inherits its delegate & delegateQueue from its parent. 74 | 75 | [connectedSockets addObject:newSocket]; 76 | } 77 | 78 | - (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err 79 | { 80 | [connectedSockets removeObject:sock]; 81 | } 82 | 83 | - (void)netServiceDidPublish:(NSNetService *)ns 84 | { 85 | DDLogInfo(@"Bonjour Service Published: domain(%@) type(%@) name(%@) port(%i)", 86 | [ns domain], [ns type], [ns name], (int)[ns port]); 87 | } 88 | 89 | - (void)netService:(NSNetService *)ns didNotPublish:(NSDictionary *)errorDict 90 | { 91 | // Override me to do something here... 92 | // 93 | // Note: This method in invoked on our bonjour thread. 94 | 95 | DDLogError(@"Failed to Publish Service: domain(%@) type(%@) name(%@) - %@", 96 | [ns domain], [ns type], [ns name], errorDict); 97 | } 98 | 99 | @end 100 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/BonjourServer/BonjourServer_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'BonjourServer' target in the 'BonjourServer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/BonjourServer/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/BonjourServer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // BonjourServer 4 | // 5 | // Created by Robbie Hanson on 1/27/11. 6 | // Copyright 2011 Voalte. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Desktop/ConnectTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Desktop/ConnectTest/ConnectTest-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.deusty.oss.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Desktop/ConnectTest/ConnectTest-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'ConnectTest' target in the 'ConnectTest' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Desktop/ConnectTest/ConnectTestAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class GCDAsyncSocket; 4 | 5 | 6 | @interface ConnectTestAppDelegate : NSObject { 7 | @private 8 | GCDAsyncSocket *asyncSocket; 9 | 10 | NSWindow *__unsafe_unretained window; 11 | } 12 | 13 | @property (unsafe_unretained) IBOutlet NSWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Desktop/ConnectTest/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Desktop/ConnectTest/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Desktop/ConnectTest/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ConnectTest 4 | // 5 | // Created by Robbie Hanson on 7/23/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **)argv); 14 | } 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Mobile/ConnectTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Mobile/ConnectTest/ConnectTest-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.deusty.oss.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | NSMainNibFile 30 | MainWindow 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Mobile/ConnectTest/ConnectTest-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'ConnectTest' target in the 'ConnectTest' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Mobile/ConnectTest/ConnectTestAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class ConnectTestViewController; 4 | @class GCDAsyncSocket; 5 | 6 | 7 | @interface ConnectTestAppDelegate : NSObject 8 | { 9 | GCDAsyncSocket *asyncSocket; 10 | } 11 | 12 | @property (nonatomic, strong) IBOutlet UIWindow *window; 13 | @property (nonatomic, strong) IBOutlet ConnectTestViewController *viewController; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Mobile/ConnectTest/ConnectTestViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | @interface ConnectTestViewController : UIViewController { 5 | 6 | } 7 | 8 | @property (nonatomic, strong) IBOutlet UILabel *label; 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Mobile/ConnectTest/ConnectTestViewController.m: -------------------------------------------------------------------------------- 1 | #import "ConnectTestViewController.h" 2 | 3 | 4 | @implementation ConnectTestViewController 5 | 6 | @synthesize label = _label; 7 | 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Mobile/ConnectTest/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Mobile/ConnectTest/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ConnectTest 4 | // 5 | // Created by Robbie Hanson on 7/25/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | @autoreleasepool { 14 | int retVal = UIApplicationMain(argc, argv, nil, nil); 15 | return retVal; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/Mobile/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/whiteblue3/HTTPLiveStreaming/2c991a42b114bc82890183ba96a23e6592859120/CocoaAsyncSocket/Examples/GCD/ConnectTest/Mobile/Default-568h@2x.png -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/ConnectTest/ReadMe.txt: -------------------------------------------------------------------------------- 1 | The ConnectTest projects demonstrates some of the various options available for connecting to a host, such as: 2 | 3 | - Setting connect timeouts 4 | - Connecting to secure hosts (using SSL/TLS) -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/DomainTest/DomainTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/DomainTest/DomainTest/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // DomainTest 4 | // 5 | // Created by Jonathan Diehl on 06.10.12. 6 | // Copyright (c) 2012 Jonathan Diehl. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "DomainServer.h" 12 | #import "DomainClient.h" 13 | 14 | @interface AppDelegate : NSObject 15 | 16 | @property (assign) IBOutlet NSWindow *window; 17 | @property (strong) DomainServer *server; 18 | @property (strong) NSMutableArray *clients; 19 | 20 | - (IBAction)addClient:(id)sender; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/DomainTest/DomainTest/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // DomainTest 4 | // 5 | // Created by Jonathan Diehl on 06.10.12. 6 | // Copyright (c) 2012 Jonathan Diehl. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | @synthesize server = _server; 14 | @synthesize clients = _clients; 15 | 16 | - (IBAction)addClient:(id)sender; 17 | { 18 | DomainClient *client = [[DomainClient alloc] initWithWindowNibName:@"DomainClient"]; 19 | [self.clients addObject:client]; 20 | [client connectToUrl:self.server.url]; 21 | [client showWindow:sender]; 22 | } 23 | 24 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 25 | { 26 | _clients = [NSMutableArray new]; 27 | 28 | NSError *error = nil; 29 | _server = [DomainServer new]; 30 | self.server.url = [NSURL fileURLWithPath:@"/tmp/socket"]; 31 | if (![self.server start:&error]) { 32 | [self.window presentError:error]; 33 | } 34 | 35 | [self addClient:nil]; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/DomainTest/DomainTest/DomainClient.h: -------------------------------------------------------------------------------- 1 | // 2 | // DomainClient.h 3 | // DomainTest 4 | // 5 | // Created by Jonathan Diehl on 06.10.12. 6 | // Copyright (c) 2012 Jonathan Diehl. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "GCDAsyncSocket.h" 12 | 13 | @interface DomainClient : NSWindowController 14 | 15 | @property (readonly) GCDAsyncSocket *socket; 16 | @property (strong) IBOutlet NSTextView *outputView; 17 | @property (strong) IBOutlet NSTextField *inputView; 18 | 19 | - (void)connectToUrl:(NSURL *)url; 20 | - (IBAction)send:(id)sender; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/DomainTest/DomainTest/DomainClient.m: -------------------------------------------------------------------------------- 1 | // 2 | // DomainClient.m 3 | // DomainTest 4 | // 5 | // Created by Jonathan Diehl on 06.10.12. 6 | // Copyright (c) 2012 Jonathan Diehl. All rights reserved. 7 | // 8 | 9 | #import "DomainClient.h" 10 | 11 | @implementation DomainClient 12 | 13 | @synthesize socket = _socket; 14 | @synthesize outputView = _outputView; 15 | @synthesize inputView = _inputView; 16 | 17 | - (void)connectToUrl:(NSURL *)url; 18 | { 19 | NSError *error = nil; 20 | _socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()]; 21 | if (![self.socket connectToUrl:url withTimeout:-1 error:&error]) { 22 | [self presentError:error]; 23 | } 24 | } 25 | 26 | - (IBAction)send:(id)sender; 27 | { 28 | NSData *data = [self.inputView.stringValue dataUsingEncoding:NSUTF8StringEncoding]; 29 | [self.socket writeData:data withTimeout:-1 tag:0]; 30 | self.inputView.stringValue = @""; 31 | } 32 | 33 | - (void)socket:(GCDAsyncSocket *)sock didConnectToUrl:(NSURL *)url; 34 | { 35 | NSLog(@"[Client] Connected to %@", url); 36 | [sock readDataWithTimeout:-1 tag:0]; 37 | } 38 | 39 | - (void)socketDidDisconnect:(GCDAsyncSocket *)socket withError:(NSError *)error; 40 | { 41 | NSLog(@"[Client] Closed connection: %@", error); 42 | } 43 | 44 | - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag; 45 | { 46 | NSString *text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 47 | NSLog(@"[Client] Received: %@", text); 48 | 49 | text = [text stringByAppendingString:@"\n"]; 50 | NSAttributedString *string = [[NSAttributedString alloc] initWithString:text]; 51 | NSTextStorage *storage = self.outputView.textStorage; 52 | 53 | [storage beginEditing]; 54 | [storage appendAttributedString:string]; 55 | [storage endEditing]; 56 | 57 | [sock readDataWithTimeout:-1 tag:0]; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/DomainTest/DomainTest/DomainServer.h: -------------------------------------------------------------------------------- 1 | // 2 | // DomainServer.h 3 | // DomainTest 4 | // 5 | // Created by Jonathan Diehl on 06.10.12. 6 | // Copyright (c) 2012 Jonathan Diehl. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "GCDAsyncSocket.h" 12 | 13 | @interface DomainServer : NSObject 14 | 15 | @property (readonly) GCDAsyncSocket *socket; 16 | @property (readonly) NSMutableSet *connectedSockets; 17 | @property (strong) NSURL *url; 18 | 19 | - (BOOL)start:(NSError **)error; 20 | - (void)stop; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/DomainTest/DomainTest/DomainServer.m: -------------------------------------------------------------------------------- 1 | // 2 | // DomainServer.m 3 | // DomainTest 4 | // 5 | // Created by Jonathan Diehl on 06.10.12. 6 | // Copyright (c) 2012 Jonathan Diehl. All rights reserved. 7 | // 8 | 9 | #import "DomainServer.h" 10 | 11 | @implementation DomainServer 12 | 13 | @synthesize socket = _socket; 14 | @synthesize url = _url; 15 | 16 | - (BOOL)start:(NSError **)error; 17 | { 18 | _connectedSockets = [NSMutableSet new]; 19 | _socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()]; 20 | BOOL result = [self.socket acceptOnUrl:self.url error:error]; 21 | if (result) { 22 | NSLog(@"[Server] Started at: %@", self.url.path); 23 | } 24 | return result; 25 | } 26 | 27 | - (void)stop; 28 | { 29 | _socket = nil; 30 | NSLog(@"[Server] Stopped."); 31 | } 32 | 33 | - (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket; 34 | { 35 | NSLog(@"[Server] New connection."); 36 | [self.connectedSockets addObject:newSocket]; 37 | [newSocket readDataWithTimeout:-1 tag:0]; 38 | } 39 | 40 | - (void)socketDidDisconnect:(GCDAsyncSocket *)socket withError:(NSError *)error; 41 | { 42 | [self.connectedSockets removeObject:socket]; 43 | NSLog(@"[Server] Closed connection: %@", error); 44 | } 45 | 46 | - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag; 47 | { 48 | NSString *text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 49 | NSLog(@"[Server] Received: %@", text); 50 | 51 | [sock writeData:data withTimeout:-1 tag:0]; 52 | [sock readDataWithTimeout:-1 tag:0]; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/DomainTest/DomainTest/DomainTest-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2012 Jonathan Diehl. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/DomainTest/DomainTest/DomainTest-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'DomainTest' target in the 'DomainTest' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/DomainTest/DomainTest/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/DomainTest/DomainTest/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/DomainTest/DomainTest/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // DomainTest 4 | // 5 | // Created by Jonathan Diehl on 06.10.12. 6 | // Copyright (c) 2012 Jonathan Diehl. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **)argv); 14 | } 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/EchoServer/EchoServer-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/EchoServer/EchoServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/EchoServer/EchoServerAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class GCDAsyncSocket; 4 | 5 | 6 | @interface EchoServerAppDelegate : NSObject 7 | { 8 | dispatch_queue_t socketQueue; 9 | 10 | GCDAsyncSocket *listenSocket; 11 | NSMutableArray *connectedSockets; 12 | 13 | BOOL isRunning; 14 | 15 | IBOutlet id logView; 16 | IBOutlet id portField; 17 | IBOutlet id startStopButton; 18 | 19 | NSWindow *__unsafe_unretained window; 20 | } 21 | 22 | @property (unsafe_unretained) IBOutlet NSWindow *window; 23 | 24 | - (IBAction)startStop:(id)sender; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/EchoServer/EchoServer_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'EchoServer' target in the 'EchoServer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/EchoServer/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/EchoServer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // EchoServer 4 | // 5 | // Created by Robbie Hanson on 11/4/10. 6 | // Copyright 2010 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Desktop/SimpleHTTPClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Desktop/SimpleHTTPClient/SimpleHTTPClient-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.deusty.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Desktop/SimpleHTTPClient/SimpleHTTPClient-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SimpleHTTPClient' target in the 'SimpleHTTPClient' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Desktop/SimpleHTTPClient/SimpleHTTPClientAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class GCDAsyncSocket; 4 | 5 | 6 | @interface SimpleHTTPClientAppDelegate : NSObject { 7 | @private 8 | GCDAsyncSocket *asyncSocket; 9 | 10 | NSWindow *__unsafe_unretained window; 11 | } 12 | 13 | @property (unsafe_unretained) IBOutlet NSWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Desktop/SimpleHTTPClient/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Desktop/SimpleHTTPClient/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Desktop/SimpleHTTPClient/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SimpleHTTPClient 4 | // 5 | // Created by Robbie Hanson on 7/5/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **)argv); 14 | } 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Mobile/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/whiteblue3/HTTPLiveStreaming/2c991a42b114bc82890183ba96a23e6592859120/CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Mobile/Default-568h@2x.png -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Mobile/SimpleHTTPClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Mobile/SimpleHTTPClient/SimpleHTTPClient-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.deusty.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | NSMainNibFile 30 | MainWindow 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Mobile/SimpleHTTPClient/SimpleHTTPClient-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SimpleHTTPClient' target in the 'SimpleHTTPClient' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Mobile/SimpleHTTPClient/SimpleHTTPClientAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class SimpleHTTPClientViewController; 4 | @class GCDAsyncSocket; 5 | 6 | 7 | @interface SimpleHTTPClientAppDelegate : NSObject 8 | { 9 | GCDAsyncSocket *asyncSocket; 10 | } 11 | 12 | @property (nonatomic) IBOutlet UIWindow *window; 13 | @property (nonatomic) IBOutlet SimpleHTTPClientViewController *viewController; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Mobile/SimpleHTTPClient/SimpleHTTPClientViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | @interface SimpleHTTPClientViewController : UIViewController { 5 | 6 | } 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Mobile/SimpleHTTPClient/SimpleHTTPClientViewController.m: -------------------------------------------------------------------------------- 1 | #import "SimpleHTTPClientViewController.h" 2 | 3 | 4 | @implementation SimpleHTTPClientViewController 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Mobile/SimpleHTTPClient/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/Mobile/SimpleHTTPClient/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SimpleHTTPClient 4 | // 5 | // Created by Robbie Hanson on 7/5/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | @autoreleasepool { 14 | int retVal = UIApplicationMain(argc, argv, nil, nil); 15 | return retVal; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/SimpleHTTPClient/ReadMe.txt: -------------------------------------------------------------------------------- 1 | The SimpleHTTPClient projects are just a simple demonstration of reading and writing data using GCDAsyncSocket. Obviously it's not meant to be a full fledged HTTP client. There are other excellent libraries for that task. But the HTTP protocol itself is so simple, it makes for a great example. -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Desktop/TestPreBuffer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Desktop/TestPreBuffer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | @interface AppDelegate : NSObject 5 | 6 | @property (assign) IBOutlet NSWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Desktop/TestPreBuffer/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import "TestPreBuffer.h" 3 | 4 | 5 | @implementation AppDelegate 6 | 7 | @synthesize window = _window; 8 | 9 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 10 | { 11 | [TestPreBuffer start]; 12 | } 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Desktop/TestPreBuffer/TestPreBuffer-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.deusty.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2012 __MyCompanyName__. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Desktop/TestPreBuffer/TestPreBuffer-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'TestPreBuffer' target in the 'TestPreBuffer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Desktop/TestPreBuffer/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Desktop/TestPreBuffer/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Desktop/TestPreBuffer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TestPreBuffer 4 | // 5 | // Created by Robbie Hanson on 6/7/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **)argv); 14 | } 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Mobile/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/whiteblue3/HTTPLiveStreaming/2c991a42b114bc82890183ba96a23e6592859120/CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Mobile/Default-568h@2x.png -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Mobile/TestPreBuffer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Mobile/TestPreBuffer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class ViewController; 4 | 5 | 6 | @interface AppDelegate : UIResponder 7 | 8 | @property (strong, nonatomic) UIWindow *window; 9 | @property (strong, nonatomic) ViewController *viewController; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Mobile/TestPreBuffer/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import "ViewController.h" 3 | #import "TestPreBuffer.h" 4 | 5 | 6 | @implementation AppDelegate 7 | 8 | @synthesize window; 9 | @synthesize viewController; 10 | 11 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 12 | { 13 | [TestPreBuffer start]; 14 | 15 | // Normal UI stuff 16 | 17 | window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 18 | if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 19 | viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil]; 20 | } else { 21 | viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil]; 22 | } 23 | window.rootViewController = self.viewController; 24 | [window makeKeyAndVisible]; 25 | return YES; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Mobile/TestPreBuffer/TestPreBuffer-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.deusty.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Mobile/TestPreBuffer/TestPreBuffer-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'TestPreBuffer' target in the 'TestPreBuffer' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_4_0 8 | #warning "This project uses features only available in iOS SDK 4.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Mobile/TestPreBuffer/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // TestPreBuffer 4 | // 5 | // Created by Robbie Hanson on 6/7/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Mobile/TestPreBuffer/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // TestPreBuffer 4 | // 5 | // Created by Robbie Hanson on 6/7/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad 18 | { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view, typically from a nib. 21 | } 22 | 23 | - (void)viewDidUnload 24 | { 25 | [super viewDidUnload]; 26 | // Release any retained subviews of the main view. 27 | } 28 | 29 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 30 | { 31 | if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 32 | return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 33 | } else { 34 | return YES; 35 | } 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Mobile/TestPreBuffer/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Mobile/TestPreBuffer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TestPreBuffer 4 | // 5 | // Created by Robbie Hanson on 6/7/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/TestPreBuffer/Shared/TestPreBuffer.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | @interface TestPreBuffer : NSObject 5 | 6 | + (void)start; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Desktop/UdpEchoClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Desktop/UdpEchoClient/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "GCDAsyncUdpSocket.h" 3 | 4 | @interface AppDelegate : NSObject 5 | { 6 | long tag; 7 | GCDAsyncUdpSocket *udpSocket; 8 | } 9 | 10 | @property (unsafe_unretained) IBOutlet NSWindow * window; 11 | @property IBOutlet NSTextField * addrField; 12 | @property IBOutlet NSTextField * portField; 13 | @property IBOutlet NSTextField * messageField; 14 | @property IBOutlet NSButton * sendButton; 15 | @property IBOutlet NSTextView * logView; 16 | 17 | - (IBAction)send:(id)sender; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Desktop/UdpEchoClient/UdpEchoClient-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.deusty.oss.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2011 __MyCompanyName__. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Desktop/UdpEchoClient/UdpEchoClient-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'UdpEchoClient' target in the 'UdpEchoClient' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Desktop/UdpEchoClient/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Desktop/UdpEchoClient/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Desktop/UdpEchoClient/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // UdpEchoClient 4 | // 5 | // Created by Robbie Hanson on 11/28/11. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **)argv); 14 | } 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Mobile/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/whiteblue3/HTTPLiveStreaming/2c991a42b114bc82890183ba96a23e6592859120/CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Mobile/Default-568h@2x.png -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Mobile/UdpEchoClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Mobile/UdpEchoClient/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class ViewController; 4 | 5 | 6 | @interface AppDelegate : UIResponder 7 | 8 | @property (strong, nonatomic) UIWindow *window; 9 | @property (strong, nonatomic) ViewController *viewController; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Mobile/UdpEchoClient/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import "ViewController.h" 3 | #import "DDLog.h" 4 | #import "DDTTYLogger.h" 5 | 6 | // Log levels: off, error, warn, info, verbose 7 | static const int ddLogLevel = LOG_LEVEL_VERBOSE; 8 | 9 | 10 | @implementation AppDelegate 11 | 12 | @synthesize window = _window; 13 | @synthesize viewController = _viewController; 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | // Setup our logging framework. 18 | [DDLog addLogger:[DDTTYLogger sharedInstance]]; 19 | 20 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 21 | 22 | self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; 23 | self.window.rootViewController = self.viewController; 24 | 25 | [self.window makeKeyAndVisible]; 26 | return YES; 27 | } 28 | 29 | - (void)applicationWillResignActive:(UIApplication *)application 30 | { 31 | } 32 | 33 | - (void)applicationDidEnterBackground:(UIApplication *)application 34 | { 35 | } 36 | 37 | - (void)applicationWillEnterForeground:(UIApplication *)application 38 | { 39 | } 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application 42 | { 43 | } 44 | 45 | - (void)applicationWillTerminate:(UIApplication *)application 46 | { 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Mobile/UdpEchoClient/UdpEchoClient-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.deusty.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Mobile/UdpEchoClient/UdpEchoClient-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'UdpEchoClient' target in the 'UdpEchoClient' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_4_0 8 | #warning "This project uses features only available in iOS SDK 4.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Mobile/UdpEchoClient/ViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "GCDAsyncUdpSocket.h" 3 | 4 | @interface ViewController : UIViewController 5 | { 6 | IBOutlet UITextField *addrField; 7 | IBOutlet UITextField *portField; 8 | IBOutlet UITextField *messageField; 9 | IBOutlet UIWebView *webView; 10 | } 11 | 12 | - (IBAction)send:(id)sender; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Mobile/UdpEchoClient/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoClient/Mobile/UdpEchoClient/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // UdpEchoClient 4 | // 5 | // Created by Robbie Hanson on 4/5/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Desktop/UdpEchoServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Desktop/UdpEchoServer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "GCDAsyncUdpSocket.h" 3 | 4 | 5 | @interface AppDelegate : NSObject 6 | { 7 | GCDAsyncUdpSocket *udpSocket; 8 | BOOL isRunning; 9 | } 10 | 11 | @property (unsafe_unretained) IBOutlet NSWindow *window; 12 | @property IBOutlet NSTextField *portField; 13 | @property IBOutlet NSButton *startStopButton; 14 | @property IBOutlet NSTextView *logView; 15 | 16 | - (IBAction)startStopButtonPressed:(id)sender; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Desktop/UdpEchoServer/UdpEchoServer-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.deusty.oss.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2011 __MyCompanyName__. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Desktop/UdpEchoServer/UdpEchoServer-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'UdpEchoServer' target in the 'UdpEchoServer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Desktop/UdpEchoServer/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Desktop/UdpEchoServer/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Desktop/UdpEchoServer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // UdpEchoServer 4 | // 5 | // Created by Robbie Hanson on 11/23/11. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **)argv); 14 | } 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Mobile/UdpEchoServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Mobile/UdpEchoServer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class ViewController; 4 | 5 | 6 | @interface AppDelegate : UIResponder 7 | 8 | @property (strong, nonatomic) UIWindow *window; 9 | @property (strong, nonatomic) ViewController *viewController; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Mobile/UdpEchoServer/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import "ViewController.h" 3 | #import "DDLog.h" 4 | #import "DDTTYLogger.h" 5 | 6 | // Log levels: off, error, warn, info, verbose 7 | static const int ddLogLevel = LOG_LEVEL_VERBOSE; 8 | 9 | 10 | @implementation AppDelegate 11 | 12 | @synthesize window = _window; 13 | @synthesize viewController = _viewController; 14 | 15 | 16 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 17 | { 18 | // Setup our logging framework. 19 | 20 | [DDLog addLogger:[DDTTYLogger sharedInstance]]; 21 | 22 | // Setup UI 23 | 24 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 25 | self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; 26 | self.window.rootViewController = self.viewController; 27 | [self.window makeKeyAndVisible]; 28 | return YES; 29 | } 30 | 31 | - (void)applicationWillResignActive:(UIApplication *)application 32 | { 33 | } 34 | 35 | - (void)applicationDidEnterBackground:(UIApplication *)application 36 | { 37 | } 38 | 39 | - (void)applicationWillEnterForeground:(UIApplication *)application 40 | { 41 | } 42 | 43 | - (void)applicationDidBecomeActive:(UIApplication *)application 44 | { 45 | } 46 | 47 | - (void)applicationWillTerminate:(UIApplication *)application 48 | { 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Mobile/UdpEchoServer/UdpEchoServer-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.deusty.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Mobile/UdpEchoServer/UdpEchoServer-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'UdpEchoServer' target in the 'UdpEchoServer' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_4_0 8 | #warning "This project uses features only available in iOS SDK 4.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Mobile/UdpEchoServer/ViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "GCDAsyncUdpSocket.h" 3 | 4 | @interface ViewController : UIViewController 5 | { 6 | IBOutlet UITextField *portField; 7 | IBOutlet UIButton *startStopButton; 8 | IBOutlet UIWebView *webView; 9 | } 10 | 11 | - (IBAction)startStop:(id)sender; 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Mobile/UdpEchoServer/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/GCD/UdpEchoServer/Mobile/UdpEchoServer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // UdpEchoServer 4 | // 5 | // Created by Robbie Hanson on 4/8/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/EchoServer/AppController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class AsyncSocket; 4 | 5 | @interface AppController : NSObject 6 | { 7 | AsyncSocket *listenSocket; 8 | NSMutableArray *connectedSockets; 9 | 10 | BOOL isRunning; 11 | 12 | IBOutlet id logView; 13 | IBOutlet id portField; 14 | IBOutlet id startStopButton; 15 | } 16 | - (IBAction)startStop:(id)sender; 17 | @end 18 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/EchoServer/EchoServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/EchoServer/EchoServer_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'EchoServer' target in the 'EchoServer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/EchoServer/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/whiteblue3/HTTPLiveStreaming/2c991a42b114bc82890183ba96a23e6592859120/CocoaAsyncSocket/Examples/RunLoop/EchoServer/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/EchoServer/English.lproj/MainMenu.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/whiteblue3/HTTPLiveStreaming/2c991a42b114bc82890183ba96a23e6592859120/CocoaAsyncSocket/Examples/RunLoop/EchoServer/English.lproj/MainMenu.nib/keyedobjects.nib -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/EchoServer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.yourcompany.EchoServer 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | NSMainNibFile 24 | MainMenu 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/EchoServer/Instructions.txt: -------------------------------------------------------------------------------- 1 | First, build and run the EchoServer. 2 | You can set it to run on a specific port, or allow to pick an available port. 3 | Now start the echo server. It will output the port it started on. 4 | 5 | You can now use telnet to connect to the echo server and test it. 6 | Using the Terminal (/Applications/Utilities/Terminal.app) 7 | type in the following: 8 | telnet localhost [port] 9 | 10 | where "[port]" is replaced by the port the Echo server is running on. 11 | 12 | Type in anything you want, and hit return. 13 | Whatever you typed in will be displayed in the Echo Server, and echoed back to you. 14 | 15 | To end your telnet session hit Ctrl-], and type "quit". -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/EchoServer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // EchoServer 4 | // 5 | // Created by Robbie Hanson on 7/10/08. 6 | // Copyright __MyCompanyName__ 2008. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/InterfaceTest/Classes/InterfaceTestAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class InterfaceTestViewController; 4 | @class AsyncSocket; 5 | 6 | 7 | @interface InterfaceTestAppDelegate : NSObject 8 | { 9 | CFHostRef host; 10 | AsyncSocket *asyncSocket; 11 | 12 | UIWindow *window; 13 | InterfaceTestViewController *viewController; 14 | } 15 | 16 | @property (nonatomic) IBOutlet UIWindow *window; 17 | @property (nonatomic) IBOutlet InterfaceTestViewController *viewController; 18 | 19 | @end 20 | 21 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/InterfaceTest/Classes/InterfaceTestViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // InterfaceTestViewController.h 3 | // InterfaceTest 4 | // 5 | // Created by Robbie Hanson on 10/15/10. 6 | // Copyright 2010 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface InterfaceTestViewController : UIViewController { 12 | 13 | } 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/InterfaceTest/Classes/InterfaceTestViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // InterfaceTestViewController.m 3 | // InterfaceTest 4 | // 5 | // Created by Robbie Hanson on 10/15/10. 6 | // Copyright 2010 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "InterfaceTestViewController.h" 10 | 11 | @implementation InterfaceTestViewController 12 | 13 | 14 | 15 | /* 16 | // The designated initializer. Override to perform setup that is required before the view is loaded. 17 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 18 | if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { 19 | // Custom initialization 20 | } 21 | return self; 22 | } 23 | */ 24 | 25 | /* 26 | // Implement loadView to create a view hierarchy programmatically, without using a nib. 27 | - (void)loadView { 28 | } 29 | */ 30 | 31 | 32 | /* 33 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 34 | - (void)viewDidLoad { 35 | [super viewDidLoad]; 36 | } 37 | */ 38 | 39 | 40 | /* 41 | // Override to allow orientations other than the default portrait orientation. 42 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 43 | // Return YES for supported orientations 44 | return (interfaceOrientation == UIInterfaceOrientationPortrait); 45 | } 46 | */ 47 | 48 | - (void)didReceiveMemoryWarning { 49 | // Releases the view if it doesn't have a superview. 50 | [super didReceiveMemoryWarning]; 51 | 52 | // Release any cached data, images, etc that aren't in use. 53 | } 54 | 55 | - (void)viewDidUnload { 56 | // Release any retained subviews of the main view. 57 | // e.g. self.myOutlet = nil; 58 | } 59 | 60 | 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/InterfaceTest/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/whiteblue3/HTTPLiveStreaming/2c991a42b114bc82890183ba96a23e6592859120/CocoaAsyncSocket/Examples/RunLoop/InterfaceTest/Default-568h@2x.png -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/InterfaceTest/InterfaceTest-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/InterfaceTest/InterfaceTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/InterfaceTest/InterfaceTest_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'InterfaceTest' target in the 'InterfaceTest' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/InterfaceTest/Readme.txt: -------------------------------------------------------------------------------- 1 | InterfaceTest is an iPhone project that demonstrates some of AsyncSocket's interface abilities. 2 | 3 | Most machines have multiple network interfaces. For example: 4 | - Ethernet 5 | - WiFi 6 | - 3G (cellular) 7 | - Bluetooth 8 | - Loopback (local machine only) 9 | 10 | Which leads to the question: 11 | If you are setting up sockets, which interface will your socket be running on? 12 | 13 | By default, if you don't specify an inteface, then the following rules generally apply: 14 | 15 | - Server sockets (listening/accepting) will accept incoming connections on any inteface. 16 | - Client sockets (connecting) will make outgoing connections on the primary interface. 17 | 18 | The primary interface on iPhone is WiFi. 19 | The primary interface on Mac is configurable via system preferences. 20 | 21 | But you can specify a particular interface using AsyncSocket. There are various examples of when one might want to do this. 22 | 23 | - You're trying to make a bluetooth connection. 24 | 25 | - Your iPhone app only supports WiFi, so you need to ensure your socket is only using the WiFi interface. 26 | 27 | - You want to create a local-only server socket on Mac for inter-process communication. You want to ensure only processes running on the local device can connect to your server. 28 | 29 | 30 | The IntefaceTest project demonstrates specifying a particular interface to use for an outgoing connection to google.com. You can force either the WiFi interface or the 3G/cellular interface. -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/InterfaceTest/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // InterfaceTest 4 | // 5 | // Created by Robbie Hanson on 10/15/10. 6 | // Copyright 2010 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) { 12 | 13 | @autoreleasepool { 14 | int retVal = UIApplicationMain(argc, argv, nil, nil); 15 | return retVal; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoClient/UdpEchoClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoClient/UdpEchoClient/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "AsyncUdpSocket.h" 3 | 4 | 5 | @interface AppDelegate : NSObject 6 | { 7 | long tag; 8 | AsyncUdpSocket *udpSocket; 9 | } 10 | 11 | @property (assign) IBOutlet NSWindow *window; 12 | 13 | @property IBOutlet NSTextField * addrField; 14 | @property IBOutlet NSTextField * portField; 15 | @property IBOutlet NSTextField * messageField; 16 | @property IBOutlet NSButton * sendButton; 17 | @property IBOutlet NSTextView * logView; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoClient/UdpEchoClient/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #define FORMAT(format, ...) [NSString stringWithFormat:(format), ##__VA_ARGS__] 4 | 5 | 6 | @implementation AppDelegate 7 | 8 | @synthesize window = _window; 9 | @synthesize addrField; 10 | @synthesize portField; 11 | @synthesize messageField; 12 | @synthesize sendButton; 13 | @synthesize logView; 14 | 15 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 16 | { 17 | udpSocket = [[AsyncUdpSocket alloc] initWithDelegate:self]; 18 | 19 | NSError *error = nil; 20 | 21 | if (![udpSocket bindToPort:0 error:&error]) 22 | { 23 | NSLog(@"Error binding: %@", error); 24 | return; 25 | } 26 | 27 | [udpSocket receiveWithTimeout:-1 tag:0]; 28 | 29 | NSLog(@"Ready"); 30 | } 31 | 32 | - (void)scrollToBottom 33 | { 34 | NSScrollView *scrollView = [logView enclosingScrollView]; 35 | NSPoint newScrollOrigin; 36 | 37 | if ([[scrollView documentView] isFlipped]) 38 | newScrollOrigin = NSMakePoint(0.0F, NSMaxY([[scrollView documentView] frame])); 39 | else 40 | newScrollOrigin = NSMakePoint(0.0F, 0.0F); 41 | 42 | [[scrollView documentView] scrollPoint:newScrollOrigin]; 43 | } 44 | 45 | - (void)logError:(NSString *)msg 46 | { 47 | NSString *paragraph = [NSString stringWithFormat:@"%@\n", msg]; 48 | 49 | NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithCapacity:1]; 50 | [attributes setObject:[NSColor redColor] forKey:NSForegroundColorAttributeName]; 51 | 52 | NSAttributedString *as = [[NSAttributedString alloc] initWithString:paragraph attributes:attributes]; 53 | 54 | [[logView textStorage] appendAttributedString:as]; 55 | [self scrollToBottom]; 56 | } 57 | 58 | - (void)logInfo:(NSString *)msg 59 | { 60 | NSString *paragraph = [NSString stringWithFormat:@"%@\n", msg]; 61 | 62 | NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithCapacity:1]; 63 | [attributes setObject:[NSColor purpleColor] forKey:NSForegroundColorAttributeName]; 64 | 65 | NSAttributedString *as = [[NSAttributedString alloc] initWithString:paragraph attributes:attributes]; 66 | 67 | [[logView textStorage] appendAttributedString:as]; 68 | [self scrollToBottom]; 69 | } 70 | 71 | - (void)logMessage:(NSString *)msg 72 | { 73 | NSString *paragraph = [NSString stringWithFormat:@"%@\n", msg]; 74 | 75 | NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithCapacity:1]; 76 | [attributes setObject:[NSColor blackColor] forKey:NSForegroundColorAttributeName]; 77 | 78 | NSAttributedString *as = [[NSAttributedString alloc] initWithString:paragraph attributes:attributes]; 79 | 80 | [[logView textStorage] appendAttributedString:as]; 81 | [self scrollToBottom]; 82 | } 83 | 84 | - (IBAction)send:(id)sender 85 | { 86 | NSString *host = [addrField stringValue]; 87 | if ([host length] == 0) 88 | { 89 | [self logError:@"Address required"]; 90 | return; 91 | } 92 | 93 | int port = [portField intValue]; 94 | if (port <= 0 || port > 65535) 95 | { 96 | [self logError:@"Valid port required"]; 97 | return; 98 | } 99 | 100 | NSString *msg = [messageField stringValue]; 101 | if ([msg length] == 0) 102 | { 103 | [self logError:@"Message required"]; 104 | return; 105 | } 106 | 107 | NSData *data = [msg dataUsingEncoding:NSUTF8StringEncoding]; 108 | [udpSocket sendData:data toHost:host port:port withTimeout:-1 tag:tag]; 109 | 110 | [self logMessage:FORMAT(@"SENT (%i): %@", (int)tag, msg)]; 111 | 112 | tag++; 113 | } 114 | 115 | - (void)onUdpSocket:(AsyncUdpSocket *)sock didSendDataWithTag:(long)tag 116 | { 117 | // You could add checks here 118 | } 119 | 120 | - (void)onUdpSocket:(AsyncUdpSocket *)sock didNotSendDataWithTag:(long)tag dueToError:(NSError *)error 121 | { 122 | // You could add checks here 123 | } 124 | 125 | - (BOOL)onUdpSocket:(AsyncUdpSocket *)sock 126 | didReceiveData:(NSData *)data 127 | withTag:(long)tag 128 | fromHost:(NSString *)host 129 | port:(UInt16)port 130 | { 131 | NSString *msg = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 132 | if (msg) 133 | { 134 | [self logMessage:FORMAT(@"RECV: %@", msg)]; 135 | } 136 | else 137 | { 138 | [self logInfo:FORMAT(@"RECV: Unknown message from: %@:%hu", host, port)]; 139 | } 140 | 141 | [udpSocket receiveWithTimeout:-1 tag:0]; 142 | return YES; 143 | } 144 | 145 | @end 146 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoClient/UdpEchoClient/UdpEchoClient-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.deusty.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2012 __MyCompanyName__. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoClient/UdpEchoClient/UdpEchoClient-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'UdpEchoClient' target in the 'UdpEchoClient' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoClient/UdpEchoClient/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoClient/UdpEchoClient/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoClient/UdpEchoClient/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // UdpEchoClient 4 | // 5 | // Created by Robbie Hanson on 4/1/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **)argv); 14 | } 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoServer/UdpEchoServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoServer/UdpEchoServer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "AsyncUdpSocket.h" 3 | 4 | 5 | @interface AppDelegate : NSObject 6 | { 7 | AsyncUdpSocket *udpSocket; 8 | BOOL isRunning; 9 | } 10 | 11 | @property (unsafe_unretained) IBOutlet NSWindow *window; 12 | 13 | @property IBOutlet NSTextField *portField; 14 | @property IBOutlet NSButton *startStopButton; 15 | @property IBOutlet NSTextView *logView; 16 | 17 | - (IBAction)startStopButtonPressed:(id)sender; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoServer/UdpEchoServer/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #define FORMAT(format, ...) [NSString stringWithFormat:(format), ##__VA_ARGS__] 4 | 5 | 6 | @implementation AppDelegate 7 | 8 | @synthesize window = _window; 9 | @synthesize portField; 10 | @synthesize startStopButton; 11 | @synthesize logView; 12 | 13 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 14 | { 15 | udpSocket = [[AsyncUdpSocket alloc] initWithDelegate:self]; 16 | } 17 | 18 | - (void)awakeFromNib 19 | { 20 | [logView setEnabledTextCheckingTypes:0]; 21 | [logView setAutomaticSpellingCorrectionEnabled:NO]; 22 | } 23 | 24 | - (void)scrollToBottom 25 | { 26 | NSScrollView *scrollView = [logView enclosingScrollView]; 27 | NSPoint newScrollOrigin; 28 | 29 | if ([[scrollView documentView] isFlipped]) 30 | newScrollOrigin = NSMakePoint(0.0F, NSMaxY([[scrollView documentView] frame])); 31 | else 32 | newScrollOrigin = NSMakePoint(0.0F, 0.0F); 33 | 34 | [[scrollView documentView] scrollPoint:newScrollOrigin]; 35 | } 36 | 37 | - (void)logError:(NSString *)msg 38 | { 39 | NSString *paragraph = [NSString stringWithFormat:@"%@\n", msg]; 40 | 41 | NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithCapacity:1]; 42 | [attributes setObject:[NSColor redColor] forKey:NSForegroundColorAttributeName]; 43 | 44 | NSAttributedString *as = [[NSAttributedString alloc] initWithString:paragraph attributes:attributes]; 45 | 46 | [[logView textStorage] appendAttributedString:as]; 47 | [self scrollToBottom]; 48 | } 49 | 50 | - (void)logInfo:(NSString *)msg 51 | { 52 | NSString *paragraph = [NSString stringWithFormat:@"%@\n", msg]; 53 | 54 | NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithCapacity:1]; 55 | [attributes setObject:[NSColor purpleColor] forKey:NSForegroundColorAttributeName]; 56 | 57 | NSAttributedString *as = [[NSAttributedString alloc] initWithString:paragraph attributes:attributes]; 58 | 59 | [[logView textStorage] appendAttributedString:as]; 60 | [self scrollToBottom]; 61 | } 62 | 63 | - (void)logMessage:(NSString *)msg 64 | { 65 | NSString *paragraph = [NSString stringWithFormat:@"%@\n", msg]; 66 | 67 | NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithCapacity:1]; 68 | [attributes setObject:[NSColor blackColor] forKey:NSForegroundColorAttributeName]; 69 | 70 | NSAttributedString *as = [[NSAttributedString alloc] initWithString:paragraph attributes:attributes]; 71 | 72 | [[logView textStorage] appendAttributedString:as]; 73 | [self scrollToBottom]; 74 | } 75 | 76 | - (IBAction)startStopButtonPressed:(id)sender 77 | { 78 | if (isRunning) 79 | { 80 | // STOP udp echo server 81 | 82 | [udpSocket close]; 83 | 84 | [self logInfo:@"Stopped Udp Echo server"]; 85 | isRunning = false; 86 | 87 | [portField setEnabled:YES]; 88 | [startStopButton setTitle:@"Start"]; 89 | } 90 | else 91 | { 92 | // START udp echo server 93 | 94 | int port = [portField intValue]; 95 | if (port < 0 || port > 65535) 96 | { 97 | [portField setStringValue:@""]; 98 | port = 0; 99 | } 100 | 101 | NSError *error = nil; 102 | 103 | if (![udpSocket bindToPort:port error:&error]) 104 | { 105 | [self logError:FORMAT(@"Error starting server (bind): %@", error)]; 106 | return; 107 | } 108 | 109 | [udpSocket receiveWithTimeout:-1 tag:0]; 110 | 111 | [self logInfo:FORMAT(@"Udp Echo server started on port %hu", [udpSocket localPort])]; 112 | isRunning = YES; 113 | 114 | [portField setEnabled:NO]; 115 | [startStopButton setTitle:@"Stop"]; 116 | } 117 | } 118 | 119 | - (BOOL)onUdpSocket:(AsyncUdpSocket *)sock 120 | didReceiveData:(NSData *)data 121 | withTag:(long)tag 122 | fromHost:(NSString *)host 123 | port:(UInt16)port 124 | { 125 | NSString *msg = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 126 | if (msg) 127 | { 128 | [self logMessage:msg]; 129 | } 130 | else 131 | { 132 | [self logError:@"Error converting received data into UTF-8 String"]; 133 | } 134 | 135 | [udpSocket sendData:data toHost:host port:port withTimeout:-1 tag:0]; 136 | [udpSocket receiveWithTimeout:-1 tag:0]; 137 | 138 | return YES; 139 | } 140 | 141 | @end 142 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoServer/UdpEchoServer/UdpEchoServer-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.deusty.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2012 __MyCompanyName__. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoServer/UdpEchoServer/UdpEchoServer-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'UdpEchoServer' target in the 'UdpEchoServer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoServer/UdpEchoServer/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoServer/UdpEchoServer/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Examples/RunLoop/UdpEchoServer/UdpEchoServer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // UdpEchoServer 4 | // 5 | // Created by Robbie Hanson on 4/1/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **)argv); 14 | } 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Source/CocoaAsyncSocket.h: -------------------------------------------------------------------------------- 1 | // 2 | // CocoaAsyncSocket.h 3 | // CocoaAsyncSocket 4 | // 5 | // Created by Derek Clarkson on 10/08/2015. 6 | // Copyright © 2015 Robbie Hanson. All rights reserved. 7 | // 8 | 9 | @import Foundation; 10 | 11 | //! Project version number for CocoaAsyncSocket. 12 | FOUNDATION_EXPORT double cocoaAsyncSocketVersionNumber; 13 | 14 | //! Project version string for CocoaAsyncSocket. 15 | FOUNDATION_EXPORT const unsigned char cocoaAsyncSocketVersionString[]; 16 | 17 | #import 18 | #import 19 | #import 20 | #import 21 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Source/GCD/Documentation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Welcome to the CocoaAsyncSocket project!

5 | 6 |

7 | A wealth of documentation can be found on the Google Code homepage:
8 | https://github.com/robbiehanson/CocoaAsyncSocket 9 |

10 | 11 |

12 | If you are new to networking, it is recommended you start by reading the Intro page:
13 | https://github.com/robbiehanson/CocoaAsyncSocket/wiki/Intro 14 |

15 | 16 |

17 | If you are a seasoned networking professional, with 10+ years of experience writing low-level socket code, 18 | and detailed knowledge of the underlying BSD networking stack, then you can skip the CommonPitfalls page.
19 | Otherwise, it should be considered mandatory reading:
20 | https://github.com/robbiehanson/CocoaAsyncSocket/wiki/CommonPitfalls 21 |

22 | 23 |

24 | A little bit of investment in your knowledge and understanding of networking fundamentals can go a long way.
25 | And it can save you a LOT of time and frustration in the long run. 26 |

27 | 28 |

29 | Your first goto for reference should ALWAYS be the header files. They are extremely well documented. Please read them. 30 |

31 | 32 |

33 | Did I mention you should read the headers? They're docemented very nicely, in plain english. 34 |

35 | 36 |

37 | If you have any questions you are welcome to post to the CocoaAsyncSocket mailing list:
38 | http://groups.google.com/group/cocoaasyncsocket
39 |
40 | The list is archived, and available for browsing online.
41 | You may be able to instantly find the answer you're looking for with a quick search.
42 |

43 | 44 |

We hope the CocoaAsyncSocket project can provide you with powerful and easy to use networking libraries.

45 | 46 | 47 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Source/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 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Source/RunLoop/Documentation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Welcome to the CocoaAsyncSocket project!

5 | 6 |

7 | A wealth of documentation can be found on the Google Code homepage:
8 | https://github.com/robbiehanson/CocoaAsyncSocket 9 |

10 | 11 |

12 | If you are new to networking, it is recommended you start by reading the Intro page:
13 | https://github.com/robbiehanson/CocoaAsyncSocket/wiki/Intro 14 |

15 | 16 |

17 | If you are a seasoned networking professional, with 10+ years of experience writing low-level socket code, 18 | and detailed knowledge of the underlying BSD networking stack, then you can skip the CommonPitfalls page.
19 | Otherwise, it should be considered mandatory reading:
20 | https://github.com/robbiehanson/CocoaAsyncSocket/wiki/CommonPitfalls 21 |

22 | 23 |

24 | A little bit of investment in your knowledge and understanding of networking fundamentals can go a long way.
25 | And it can save you a LOT of time and frustration in the long run. 26 |

27 | 28 |

29 | Your first goto for reference should ALWAYS be the header files. They are extremely well documented. Please read them. 30 |

31 | 32 |

33 | Did I mention you should read the headers? They're docemented very nicely, in plain english. 34 |

35 | 36 |

37 | If you have any questions you are welcome to post to the CocoaAsyncSocket mailing list:
38 | http://groups.google.com/group/cocoaasyncsocket
39 |
40 | The list is archived, and available for browsing online.
41 | You may be able to instantly find the answer you're looking for with a quick search.
42 |

43 | 44 |

We hope the CocoaAsyncSocket project can provide you with powerful and easy to use networking libraries.

45 | 46 | 47 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/DDASLLogger.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import "DDLog.h" 5 | 6 | /** 7 | * Welcome to Cocoa Lumberjack! 8 | * 9 | * The project page has a wealth of documentation if you have any questions. 10 | * https://github.com/CocoaLumberjack/CocoaLumberjack 11 | * 12 | * If you're new to the project you may wish to read the "Getting Started" wiki. 13 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted 14 | * 15 | * 16 | * This class provides a logger for the Apple System Log facility. 17 | * 18 | * As described in the "Getting Started" page, 19 | * the traditional NSLog() function directs it's output to two places: 20 | * 21 | * - Apple System Log 22 | * - StdErr (if stderr is a TTY) so log statements show up in Xcode console 23 | * 24 | * To duplicate NSLog() functionality you can simply add this logger and a tty logger. 25 | * However, if you instead choose to use file logging (for faster performance), 26 | * you may choose to use a file logger and a tty logger. 27 | **/ 28 | 29 | @interface DDASLLogger : DDAbstractLogger 30 | { 31 | aslclient client; 32 | } 33 | 34 | + (instancetype)sharedInstance; 35 | 36 | // Inherited from DDAbstractLogger 37 | 38 | // - (id )logFormatter; 39 | // - (void)setLogFormatter:(id )formatter; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/DDASLLogger.m: -------------------------------------------------------------------------------- 1 | #import "DDASLLogger.h" 2 | 3 | #import 4 | 5 | /** 6 | * Welcome to Cocoa Lumberjack! 7 | * 8 | * The project page has a wealth of documentation if you have any questions. 9 | * https://github.com/CocoaLumberjack/CocoaLumberjack 10 | * 11 | * If you're new to the project you may wish to read the "Getting Started" wiki. 12 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted 13 | **/ 14 | 15 | #if ! __has_feature(objc_arc) 16 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC). 17 | #endif 18 | 19 | 20 | @implementation DDASLLogger 21 | 22 | static DDASLLogger *sharedInstance; 23 | 24 | /** 25 | * The runtime sends initialize to each class in a program exactly one time just before the class, 26 | * or any class that inherits from it, is sent its first message from within the program. (Thus the 27 | * method may never be invoked if the class is not used.) The runtime sends the initialize message to 28 | * classes in a thread-safe manner. Superclasses receive this message before their subclasses. 29 | * 30 | * This method may also be called directly (assumably by accident), hence the safety mechanism. 31 | **/ 32 | + (void)initialize 33 | { 34 | static BOOL initialized = NO; 35 | if (!initialized) 36 | { 37 | initialized = YES; 38 | 39 | sharedInstance = [[[self class] alloc] init]; 40 | } 41 | } 42 | 43 | + (instancetype)sharedInstance 44 | { 45 | return sharedInstance; 46 | } 47 | 48 | - (id)init 49 | { 50 | if (sharedInstance != nil) 51 | { 52 | return nil; 53 | } 54 | 55 | if ((self = [super init])) 56 | { 57 | // A default asl client is provided for the main thread, 58 | // but background threads need to create their own client. 59 | 60 | client = asl_open(NULL, "com.apple.console", 0); 61 | } 62 | return self; 63 | } 64 | 65 | - (void)logMessage:(DDLogMessage *)logMessage 66 | { 67 | NSString *logMsg = logMessage->logMsg; 68 | 69 | if (formatter) 70 | { 71 | logMsg = [formatter formatLogMessage:logMessage]; 72 | } 73 | 74 | if (logMsg) 75 | { 76 | const char *msg = [logMsg UTF8String]; 77 | 78 | int aslLogLevel; 79 | switch (logMessage->logFlag) 80 | { 81 | // Note: By default ASL will filter anything above level 5 (Notice). 82 | // So our mappings shouldn't go above that level. 83 | 84 | case LOG_FLAG_ERROR : aslLogLevel = ASL_LEVEL_ALERT; break; 85 | case LOG_FLAG_WARN : aslLogLevel = ASL_LEVEL_CRIT; break; 86 | case LOG_FLAG_INFO : aslLogLevel = ASL_LEVEL_ERR; break; 87 | case LOG_FLAG_DEBUG : aslLogLevel = ASL_LEVEL_WARNING; break; 88 | default : aslLogLevel = ASL_LEVEL_NOTICE; break; 89 | } 90 | 91 | asl_log(client, NULL, aslLogLevel, "%s", msg); 92 | } 93 | } 94 | 95 | - (NSString *)loggerName 96 | { 97 | return @"cocoa.lumberjack.aslLogger"; 98 | } 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/DDAbstractDatabaseLogger.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "DDLog.h" 4 | 5 | /** 6 | * Welcome to Cocoa Lumberjack! 7 | * 8 | * The project page has a wealth of documentation if you have any questions. 9 | * https://github.com/CocoaLumberjack/CocoaLumberjack 10 | * 11 | * If you're new to the project you may wish to read the "Getting Started" wiki. 12 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted 13 | * 14 | * 15 | * This class provides an abstract implementation of a database logger. 16 | * 17 | * That is, it provides the base implementation for a database logger to build atop of. 18 | * All that is needed for a concrete database logger is to extend this class 19 | * and override the methods in the implementation file that are prefixed with "db_". 20 | **/ 21 | 22 | @interface DDAbstractDatabaseLogger : DDAbstractLogger { 23 | @protected 24 | NSUInteger saveThreshold; 25 | NSTimeInterval saveInterval; 26 | NSTimeInterval maxAge; 27 | NSTimeInterval deleteInterval; 28 | BOOL deleteOnEverySave; 29 | 30 | BOOL saveTimerSuspended; 31 | NSUInteger unsavedCount; 32 | dispatch_time_t unsavedTime; 33 | dispatch_source_t saveTimer; 34 | dispatch_time_t lastDeleteTime; 35 | dispatch_source_t deleteTimer; 36 | } 37 | 38 | /** 39 | * Specifies how often to save the data to disk. 40 | * Since saving is an expensive operation (disk io) it is not done after every log statement. 41 | * These properties allow you to configure how/when the logger saves to disk. 42 | * 43 | * A save is done when either (whichever happens first): 44 | * 45 | * - The number of unsaved log entries reaches saveThreshold 46 | * - The amount of time since the oldest unsaved log entry was created reaches saveInterval 47 | * 48 | * You can optionally disable the saveThreshold by setting it to zero. 49 | * If you disable the saveThreshold you are entirely dependent on the saveInterval. 50 | * 51 | * You can optionally disable the saveInterval by setting it to zero (or a negative value). 52 | * If you disable the saveInterval you are entirely dependent on the saveThreshold. 53 | * 54 | * It's not wise to disable both saveThreshold and saveInterval. 55 | * 56 | * The default saveThreshold is 500. 57 | * The default saveInterval is 60 seconds. 58 | **/ 59 | @property (assign, readwrite) NSUInteger saveThreshold; 60 | @property (assign, readwrite) NSTimeInterval saveInterval; 61 | 62 | /** 63 | * It is likely you don't want the log entries to persist forever. 64 | * Doing so would allow the database to grow infinitely large over time. 65 | * 66 | * The maxAge property provides a way to specify how old a log statement can get 67 | * before it should get deleted from the database. 68 | * 69 | * The deleteInterval specifies how often to sweep for old log entries. 70 | * Since deleting is an expensive operation (disk io) is is done on a fixed interval. 71 | * 72 | * An alternative to the deleteInterval is the deleteOnEverySave option. 73 | * This specifies that old log entries should be deleted during every save operation. 74 | * 75 | * You can optionally disable the maxAge by setting it to zero (or a negative value). 76 | * If you disable the maxAge then old log statements are not deleted. 77 | * 78 | * You can optionally disable the deleteInterval by setting it to zero (or a negative value). 79 | * 80 | * If you disable both deleteInterval and deleteOnEverySave then old log statements are not deleted. 81 | * 82 | * It's not wise to enable both deleteInterval and deleteOnEverySave. 83 | * 84 | * The default maxAge is 7 days. 85 | * The default deleteInterval is 5 minutes. 86 | * The default deleteOnEverySave is NO. 87 | **/ 88 | @property (assign, readwrite) NSTimeInterval maxAge; 89 | @property (assign, readwrite) NSTimeInterval deleteInterval; 90 | @property (assign, readwrite) BOOL deleteOnEverySave; 91 | 92 | /** 93 | * Forces a save of any pending log entries (flushes log entries to disk). 94 | **/ 95 | - (void)savePendingLogEntries; 96 | 97 | /** 98 | * Removes any log entries that are older than maxAge. 99 | **/ 100 | - (void)deleteOldLogEntries; 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/DDLog+LOGV.h: -------------------------------------------------------------------------------- 1 | // 2 | // DDLog+LOGV.h 3 | // Lumberjack 4 | // 5 | // Created by Mike Pontillo on 11/20/12. 6 | // 7 | // 8 | 9 | #ifndef Lumberjack_DDLog_LOGV_h 10 | #define Lumberjack_DDLog_LOGV_h 11 | 12 | #import "DDLog.h" 13 | 14 | 15 | #define LOGV_MACRO(isAsynchronous, lvl, flg, ctx, atag, fnct, frmt, avalist) \ 16 | [DDLog log:isAsynchronous \ 17 | level:lvl \ 18 | flag:flg \ 19 | context:ctx \ 20 | file:__FILE__ \ 21 | function:fnct \ 22 | line:__LINE__ \ 23 | tag:atag \ 24 | format:frmt \ 25 | args:avalist] 26 | 27 | #define LOGV_OBJC_MACRO(async, lvl, flg, ctx, frmt, avalist) \ 28 | LOGV_MACRO(async, lvl, flg, ctx, nil, sel_getName(_cmd), frmt, avalist) 29 | 30 | #define LOGV_C_MACRO(async, lvl, flg, ctx, frmt, avalist) \ 31 | LOGV_MACRO(async, lvl, flg, ctx, nil, __FUNCTION__, frmt, avalist) 32 | 33 | 34 | 35 | #define SYNC_LOGV_OBJC_MACRO(lvl, flg, ctx, frmt, avalist) \ 36 | LOGV_OBJC_MACRO( NO, lvl, flg, ctx, frmt, avalist) 37 | 38 | #define ASYNC_LOGV_OBJC_MACRO(lvl, flg, ctx, frmt, avalist) \ 39 | LOGV_OBJC_MACRO(YES, lvl, flg, ctx, frmt, avalist) 40 | 41 | #define SYNC_LOGV_C_MACRO(lvl, flg, ctx, frmt, avalist) \ 42 | LOGV_C_MACRO( NO, lvl, flg, ctx, frmt, avalist) 43 | 44 | #define ASYNC_LOGV_C_MACRO(lvl, flg, ctx, frmt, avalist) \ 45 | LOGV_C_MACRO(YES, lvl, flg, ctx, frmt, avalist) 46 | 47 | 48 | 49 | #define LOGV_MAYBE(async, lvl, flg, ctx, fnct, frmt, avalist) \ 50 | do { if(lvl & flg) LOGV_MACRO(async, lvl, flg, ctx, nil, fnct, frmt, avalist); } while(0) 51 | 52 | #define LOGV_OBJC_MAYBE(async, lvl, flg, ctx, frmt, avalist) \ 53 | LOGV_MAYBE(async, lvl, flg, ctx, sel_getName(_cmd), frmt, avalist) 54 | 55 | #define LOGV_C_MAYBE(async, lvl, flg, ctx, frmt, avalist) \ 56 | LOGV_MAYBE(async, lvl, flg, ctx, __FUNCTION__, frmt, avalist) 57 | 58 | #define SYNC_LOGV_OBJC_MAYBE(lvl, flg, ctx, frmt, avalist) \ 59 | LOGV_OBJC_MAYBE( NO, lvl, flg, ctx, frmt, avalist) 60 | 61 | #define ASYNC_LOGV_OBJC_MAYBE(lvl, flg, ctx, frmt, avalist) \ 62 | LOGV_OBJC_MAYBE(YES, lvl, flg, ctx, frmt, avalist) 63 | 64 | #define SYNC_LOGV_C_MAYBE(lvl, flg, ctx, frmt, avalist) \ 65 | LOGV_C_MAYBE( NO, lvl, flg, ctx, frmt, avalist) 66 | 67 | #define ASYNC_LOGV_C_MAYBE(lvl, flg, ctx, frmt, avalist) \ 68 | LOGV_C_MAYBE(YES, lvl, flg, ctx, frmt, avalist) 69 | 70 | 71 | 72 | #define LOGV_OBJC_TAG_MACRO(async, lvl, flg, ctx, tag, frmt, avalist) \ 73 | LOGV_MACRO(async, lvl, flg, ctx, tag, sel_getName(_cmd), frmt, avalist) 74 | 75 | #define LOGV_C_TAG_MACRO(async, lvl, flg, ctx, tag, frmt, avalist) \ 76 | LOGV_MACRO(async, lvl, flg, ctx, tag, __FUNCTION__, frmt, avalist) 77 | 78 | #define LOGV_TAG_MAYBE(async, lvl, flg, ctx, tag, fnct, frmt, avalist) \ 79 | do { if(lvl & flg) LOGV_MACRO(async, lvl, flg, ctx, tag, fnct, frmt, avalist); } while(0) 80 | 81 | #define LOGV_OBJC_TAG_MAYBE(async, lvl, flg, ctx, tag, frmt, avalist) \ 82 | LOGV_TAG_MAYBE(async, lvl, flg, ctx, tag, sel_getName(_cmd), frmt, avalist) 83 | 84 | #define LOGV_C_TAG_MAYBE(async, lvl, flg, ctx, tag, frmt, avalist) \ 85 | LOGV_TAG_MAYBE(async, lvl, flg, ctx, tag, __FUNCTION__, frmt, avalist) 86 | 87 | 88 | 89 | #define DDLogvError(frmt, avalist) LOGV_OBJC_MAYBE(LOG_ASYNC_ERROR, ddLogLevel, LOG_FLAG_ERROR, 0, frmt, avalist) 90 | #define DDLogvWarn(frmt, avalist) LOGV_OBJC_MAYBE(LOG_ASYNC_WARN, ddLogLevel, LOG_FLAG_WARN, 0, frmt, avalist) 91 | #define DDLogvInfo(frmt, avalist) LOGV_OBJC_MAYBE(LOG_ASYNC_INFO, ddLogLevel, LOG_FLAG_INFO, 0, frmt, avalist) 92 | #define DDLogvVerbose(frmt, avalist) LOGV_OBJC_MAYBE(LOG_ASYNC_VERBOSE, ddLogLevel, LOG_FLAG_VERBOSE, 0, frmt, avalist) 93 | 94 | #define DDLogvCError(frmt, avalist) LOGV_C_MAYBE(LOG_ASYNC_ERROR, ddLogLevel, LOG_FLAG_ERROR, 0, frmt, avalist) 95 | #define DDLogvCWarn(frmt, avalist) LOGV_C_MAYBE(LOG_ASYNC_WARN, ddLogLevel, LOG_FLAG_WARN, 0, frmt, avalist) 96 | #define DDLogvCInfo(frmt, avalist) LOGV_C_MAYBE(LOG_ASYNC_INFO, ddLogLevel, LOG_FLAG_INFO, 0, frmt, avalist) 97 | #define DDLogvCVerbose(frmt, avalist) LOGV_C_MAYBE(LOG_ASYNC_VERBOSE, ddLogLevel, LOG_FLAG_VERBOSE, 0, frmt, avalist) 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/Extensions/DDContextFilterLogFormatter.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "DDLog.h" 3 | 4 | /** 5 | * Welcome to Cocoa Lumberjack! 6 | * 7 | * The project page has a wealth of documentation if you have any questions. 8 | * https://github.com/CocoaLumberjack/CocoaLumberjack 9 | * 10 | * If you're new to the project you may wish to read the "Getting Started" page. 11 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted 12 | * 13 | * 14 | * This class provides a log formatter that filters log statements from a logging context not on the whitelist. 15 | * 16 | * A log formatter can be added to any logger to format and/or filter its output. 17 | * You can learn more about log formatters here: 18 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomFormatters 19 | * 20 | * You can learn more about logging context's here: 21 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomContext 22 | * 23 | * But here's a quick overview / refresher: 24 | * 25 | * Every log statement has a logging context. 26 | * These come from the underlying logging macros defined in DDLog.h. 27 | * The default logging context is zero. 28 | * You can define multiple logging context's for use in your application. 29 | * For example, logically separate parts of your app each have a different logging context. 30 | * Also 3rd party frameworks that make use of Lumberjack generally use their own dedicated logging context. 31 | **/ 32 | @interface DDContextWhitelistFilterLogFormatter : NSObject 33 | 34 | - (id)init; 35 | 36 | - (void)addToWhitelist:(int)loggingContext; 37 | - (void)removeFromWhitelist:(int)loggingContext; 38 | 39 | - (NSArray *)whitelist; 40 | 41 | - (BOOL)isOnWhitelist:(int)loggingContext; 42 | 43 | @end 44 | 45 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 46 | #pragma mark - 47 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 48 | 49 | /** 50 | * This class provides a log formatter that filters log statements from a logging context on the blacklist. 51 | **/ 52 | @interface DDContextBlacklistFilterLogFormatter : NSObject 53 | 54 | - (id)init; 55 | 56 | - (void)addToBlacklist:(int)loggingContext; 57 | - (void)removeFromBlacklist:(int)loggingContext; 58 | 59 | - (NSArray *)blacklist; 60 | 61 | - (BOOL)isOnBlacklist:(int)loggingContext; 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/Extensions/DDContextFilterLogFormatter.m: -------------------------------------------------------------------------------- 1 | #import "DDContextFilterLogFormatter.h" 2 | #import 3 | 4 | /** 5 | * Welcome to Cocoa Lumberjack! 6 | * 7 | * The project page has a wealth of documentation if you have any questions. 8 | * https://github.com/CocoaLumberjack/CocoaLumberjack 9 | * 10 | * If you're new to the project you may wish to read the "Getting Started" wiki. 11 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted 12 | **/ 13 | 14 | #if ! __has_feature(objc_arc) 15 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC). 16 | #endif 17 | 18 | @interface DDLoggingContextSet : NSObject 19 | 20 | - (void)addToSet:(int)loggingContext; 21 | - (void)removeFromSet:(int)loggingContext; 22 | 23 | - (NSArray *)currentSet; 24 | 25 | - (BOOL)isInSet:(int)loggingContext; 26 | 27 | @end 28 | 29 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 30 | #pragma mark - 31 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 32 | 33 | @implementation DDContextWhitelistFilterLogFormatter 34 | { 35 | DDLoggingContextSet *contextSet; 36 | } 37 | 38 | - (id)init 39 | { 40 | if ((self = [super init])) 41 | { 42 | contextSet = [[DDLoggingContextSet alloc] init]; 43 | } 44 | return self; 45 | } 46 | 47 | 48 | - (void)addToWhitelist:(int)loggingContext 49 | { 50 | [contextSet addToSet:loggingContext]; 51 | } 52 | 53 | - (void)removeFromWhitelist:(int)loggingContext 54 | { 55 | [contextSet removeFromSet:loggingContext]; 56 | } 57 | 58 | - (NSArray *)whitelist 59 | { 60 | return [contextSet currentSet]; 61 | } 62 | 63 | - (BOOL)isOnWhitelist:(int)loggingContext 64 | { 65 | return [contextSet isInSet:loggingContext]; 66 | } 67 | 68 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage 69 | { 70 | if ([self isOnWhitelist:logMessage->logContext]) 71 | return logMessage->logMsg; 72 | else 73 | return nil; 74 | } 75 | 76 | @end 77 | 78 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 79 | #pragma mark - 80 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 81 | 82 | @implementation DDContextBlacklistFilterLogFormatter 83 | { 84 | DDLoggingContextSet *contextSet; 85 | } 86 | 87 | - (id)init 88 | { 89 | if ((self = [super init])) 90 | { 91 | contextSet = [[DDLoggingContextSet alloc] init]; 92 | } 93 | return self; 94 | } 95 | 96 | 97 | - (void)addToBlacklist:(int)loggingContext 98 | { 99 | [contextSet addToSet:loggingContext]; 100 | } 101 | 102 | - (void)removeFromBlacklist:(int)loggingContext 103 | { 104 | [contextSet removeFromSet:loggingContext]; 105 | } 106 | 107 | - (NSArray *)blacklist 108 | { 109 | return [contextSet currentSet]; 110 | } 111 | 112 | - (BOOL)isOnBlacklist:(int)loggingContext 113 | { 114 | return [contextSet isInSet:loggingContext]; 115 | } 116 | 117 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage 118 | { 119 | if ([self isOnBlacklist:logMessage->logContext]) 120 | return nil; 121 | else 122 | return logMessage->logMsg; 123 | } 124 | 125 | @end 126 | 127 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 128 | #pragma mark - 129 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 130 | 131 | @implementation DDLoggingContextSet 132 | { 133 | OSSpinLock lock; 134 | NSMutableSet *set; 135 | } 136 | 137 | - (id)init 138 | { 139 | if ((self = [super init])) 140 | { 141 | set = [[NSMutableSet alloc] init]; 142 | } 143 | return self; 144 | } 145 | 146 | 147 | - (void)addToSet:(int)loggingContext 148 | { 149 | OSSpinLockLock(&lock); 150 | { 151 | [set addObject:@(loggingContext)]; 152 | } 153 | OSSpinLockUnlock(&lock); 154 | } 155 | 156 | - (void)removeFromSet:(int)loggingContext 157 | { 158 | OSSpinLockLock(&lock); 159 | { 160 | [set removeObject:@(loggingContext)]; 161 | } 162 | OSSpinLockUnlock(&lock); 163 | } 164 | 165 | - (NSArray *)currentSet 166 | { 167 | NSArray *result = nil; 168 | 169 | OSSpinLockLock(&lock); 170 | { 171 | result = [set allObjects]; 172 | } 173 | OSSpinLockUnlock(&lock); 174 | 175 | return result; 176 | } 177 | 178 | - (BOOL)isInSet:(int)loggingContext 179 | { 180 | BOOL result = NO; 181 | 182 | OSSpinLockLock(&lock); 183 | { 184 | result = [set containsObject:@(loggingContext)]; 185 | } 186 | OSSpinLockUnlock(&lock); 187 | 188 | return result; 189 | } 190 | 191 | @end 192 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/Extensions/DDMultiFormatter.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "DDLog.h" 3 | 4 | /** 5 | * Welcome to Cocoa Lumberjack! 6 | * 7 | * The project page has a wealth of documentation if you have any questions. 8 | * https://github.com/CocoaLumberjack/CocoaLumberjack 9 | * 10 | * If you're new to the project you may wish to read the "Getting Started" page. 11 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted 12 | * 13 | * 14 | * This formatter can be used to chain different formatters together. 15 | * The log message will processed in the order of the formatters added. 16 | **/ 17 | 18 | @interface DDMultiFormatter : NSObject 19 | 20 | /** 21 | * Array of chained formatters 22 | */ 23 | @property (readonly) NSArray *formatters; 24 | 25 | - (void)addFormatter:(id)formatter; 26 | - (void)removeFormatter:(id)formatter; 27 | - (void)removeAllFormatters; 28 | - (BOOL)isFormattingWithFormatter:(id)formatter; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/Extensions/DDMultiFormatter.m: -------------------------------------------------------------------------------- 1 | #import "DDMultiFormatter.h" 2 | 3 | /** 4 | * Welcome to Cocoa Lumberjack! 5 | * 6 | * The project page has a wealth of documentation if you have any questions. 7 | * https://github.com/CocoaLumberjack/CocoaLumberjack 8 | * 9 | * If you're new to the project you may wish to read the "Getting Started" page. 10 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted 11 | **/ 12 | 13 | #if TARGET_OS_IPHONE 14 | // Compiling for iOS 15 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later 16 | #define NEEDS_DISPATCH_RETAIN_RELEASE 0 17 | #else // iOS 5.X or earlier 18 | #define NEEDS_DISPATCH_RETAIN_RELEASE 1 19 | #endif 20 | #else 21 | // Compiling for Mac OS X 22 | #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later 23 | #define NEEDS_DISPATCH_RETAIN_RELEASE 0 24 | #else // Mac OS X 10.7 or earlier 25 | #define NEEDS_DISPATCH_RETAIN_RELEASE 1 26 | #endif 27 | #endif 28 | 29 | 30 | @interface DDMultiFormatter () 31 | 32 | - (DDLogMessage *)logMessageForLine:(NSString *)line originalMessage:(DDLogMessage *)message; 33 | 34 | @end 35 | 36 | 37 | @implementation DDMultiFormatter { 38 | dispatch_queue_t _queue; 39 | NSMutableArray *_formatters; 40 | } 41 | 42 | - (id)init { 43 | self = [super init]; 44 | if (self) { 45 | #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 46 | _queue = dispatch_queue_create("cocoa.lumberjack.multiformatter", DISPATCH_QUEUE_CONCURRENT); 47 | #else 48 | _queue = dispatch_queue_create("cocoa.lumberjack.multiformatter", NULL); 49 | #endif 50 | _formatters = [NSMutableArray new]; 51 | } 52 | 53 | return self; 54 | } 55 | 56 | #if NEEDS_DISPATCH_RETAIN_RELEASE 57 | - (void)dealloc { 58 | dispatch_release(_queue); 59 | } 60 | #endif 61 | 62 | #pragma mark Processing 63 | 64 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage { 65 | __block NSString *line = logMessage->logMsg; 66 | 67 | dispatch_sync(_queue, ^{ 68 | for (id formatter in _formatters) { 69 | DDLogMessage *message = [self logMessageForLine:line originalMessage:logMessage]; 70 | line = [formatter formatLogMessage:message]; 71 | 72 | if (!line) { 73 | break; 74 | } 75 | } 76 | }); 77 | 78 | return line; 79 | } 80 | 81 | - (DDLogMessage *)logMessageForLine:(NSString *)line originalMessage:(DDLogMessage *)message { 82 | DDLogMessage *newMessage = [message copy]; 83 | newMessage->logMsg = line; 84 | return newMessage; 85 | } 86 | 87 | #pragma mark Formatters 88 | 89 | - (NSArray *)formatters { 90 | __block NSArray *formatters; 91 | 92 | dispatch_sync(_queue, ^{ 93 | formatters = [_formatters copy]; 94 | }); 95 | 96 | return formatters; 97 | } 98 | 99 | - (void)addFormatter:(id)formatter { 100 | dispatch_barrier_async(_queue, ^{ 101 | [_formatters addObject:formatter]; 102 | }); 103 | } 104 | 105 | - (void)removeFormatter:(id)formatter { 106 | dispatch_barrier_async(_queue, ^{ 107 | [_formatters removeObject:formatter]; 108 | }); 109 | } 110 | 111 | - (void)removeAllFormatters { 112 | dispatch_barrier_async(_queue, ^{ 113 | [_formatters removeAllObjects]; 114 | }); 115 | } 116 | 117 | - (BOOL)isFormattingWithFormatter:(id)formatter { 118 | __block BOOL hasFormatter; 119 | 120 | dispatch_sync(_queue, ^{ 121 | hasFormatter = [_formatters containsObject:formatter]; 122 | }); 123 | 124 | return hasFormatter; 125 | } 126 | 127 | @end 128 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Source/Vendor/CocoaLumberjack/Extensions/README.txt: -------------------------------------------------------------------------------- 1 | This folder contains some sample formatters that may be helpful. 2 | 3 | Feel free to change them, extend them, or use them as the basis for your own custom formatter(s). 4 | 5 | More information about creating your own custom formatters can be found on the wiki: 6 | https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomFormatters 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Tests/CocoaAsyncSocket.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Tests/CocoaAsyncSocket.xcodeproj/xcshareddata/xcschemes/CocoaAsyncSocketTestsMac.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Tests/CocoaAsyncSocket.xcodeproj/xcshareddata/xcschemes/CocoaAsyncSocketTestsiOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Tests/CocoaAsyncSocket.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Tests/CocoaAsyncSocket.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Tests/Mac/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.chrisballinger.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Tests/Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | 3 | use_frameworks! 4 | 5 | target :CocoaAsyncSocketTestsMac do 6 | platform :osx, '10.8' 7 | pod 'CocoaAsyncSocket', :path => '../CocoaAsyncSocket.podspec' 8 | end 9 | 10 | target :CocoaAsyncSocketTestsiOS do 11 | platform :ios, '8.0' 12 | pod 'CocoaAsyncSocket', :path => '../CocoaAsyncSocket.podspec' 13 | end -------------------------------------------------------------------------------- /CocoaAsyncSocket/Tests/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CocoaAsyncSocket (7.4.2) 3 | 4 | DEPENDENCIES: 5 | - CocoaAsyncSocket (from `../CocoaAsyncSocket.podspec`) 6 | 7 | EXTERNAL SOURCES: 8 | CocoaAsyncSocket: 9 | :path: ../CocoaAsyncSocket.podspec 10 | 11 | SPEC CHECKSUMS: 12 | CocoaAsyncSocket: f5783bdedd232d91b89769bc4b5a1580aed518ad 13 | 14 | COCOAPODS: 0.38.2 15 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Tests/Shared/GCDAsyncSocketConnectionTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // GCDAsyncSocketConnectionTests.m 3 | // GCDAsyncSocketConnectionTests 4 | // 5 | // Created by Christopher Ballinger on 10/31/14. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | @import CocoaAsyncSocket; 12 | 13 | static const uint16_t kTestPort = 30301; 14 | 15 | @interface GCDAsyncSocketConnectionTests : XCTestCase 16 | @property (nonatomic, strong) GCDAsyncSocket *clientSocket; 17 | @property (nonatomic, strong) GCDAsyncSocket *serverSocket; 18 | @property (nonatomic, strong) GCDAsyncSocket *acceptedServerSocket; 19 | 20 | @property (nonatomic, strong) XCTestExpectation *expectation; 21 | @end 22 | 23 | @implementation GCDAsyncSocketConnectionTests 24 | 25 | - (void)setUp { 26 | [super setUp]; 27 | // Put setup code here. This method is called before the invocation of each test method in the class. 28 | self.clientSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()]; 29 | self.serverSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()]; 30 | } 31 | 32 | - (void)tearDown { 33 | // Put teardown code here. This method is called after the invocation of each test method in the class. 34 | [super tearDown]; 35 | [self.clientSocket disconnect]; 36 | [self.serverSocket disconnect]; 37 | [self.acceptedServerSocket disconnect]; 38 | self.clientSocket = nil; 39 | self.serverSocket = nil; 40 | self.acceptedServerSocket = nil; 41 | } 42 | 43 | - (void)testFullConnection { 44 | NSError *error = nil; 45 | BOOL success = NO; 46 | success = [self.serverSocket acceptOnPort:kTestPort error:&error]; 47 | XCTAssertTrue(success, @"Server failed setting up socket on port %d %@", kTestPort, error); 48 | success = [self.clientSocket connectToHost:@"127.0.0.1" onPort:kTestPort error:&error]; 49 | XCTAssertTrue(success, @"Client failed connecting to up server socket on port %d %@", kTestPort, error); 50 | 51 | self.expectation = [self expectationWithDescription:@"Test Full Connection"]; 52 | [self waitForExpectationsWithTimeout:30 handler:^(NSError *error) { 53 | if (error) { 54 | NSLog(@"Error establishing test connection"); 55 | } 56 | }]; 57 | } 58 | 59 | #pragma mark GCDAsyncSocketDelegate methods 60 | 61 | /** 62 | * Called when a socket accepts a connection. 63 | * Another socket is automatically spawned to handle it. 64 | * 65 | * You must retain the newSocket if you wish to handle the connection. 66 | * Otherwise the newSocket instance will be released and the spawned connection will be closed. 67 | * 68 | * By default the new socket will have the same delegate and delegateQueue. 69 | * You may, of course, change this at any time. 70 | **/ 71 | - (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket { 72 | NSLog(@"didAcceptNewSocket %@ %@", sock, newSocket); 73 | self.acceptedServerSocket = newSocket; 74 | } 75 | 76 | /** 77 | * Called when a socket connects and is ready for reading and writing. 78 | * The host parameter will be an IP address, not a DNS name. 79 | **/ 80 | - (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port { 81 | NSLog(@"didConnectToHost %@ %@ %d", sock, host, port); 82 | [self.expectation fulfill]; 83 | } 84 | 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /CocoaAsyncSocket/Tests/iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.chrisballinger.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Core/CameraEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // CameraEncoder.h 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeong-uk Park on 2016. 2. 10.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | #import "H264HWEncoder.h" 13 | 14 | #if TARGET_OS_IPHONE 15 | #import 16 | #import "AACEncoder.h" 17 | #endif 18 | 19 | #if TARGET_OS_IPHONE 20 | @interface CameraEncoder : NSObject 21 | #else 22 | @interface CameraEncoder : NSObject 23 | #endif 24 | 25 | @property (weak, nonatomic) AVCaptureVideoPreviewLayer *previewLayer; 26 | 27 | - (void) initCameraWithOutputSize:(CGSize)size; 28 | - (void) startCamera; 29 | - (void) stopCamera; 30 | 31 | @end 32 | 33 | -------------------------------------------------------------------------------- /Core/Codec/AACEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // AACEncoder.h 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeongwook Park on 2016. 1. 8.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | // AAC Software Encoder 9 | 10 | #import 11 | #import 12 | 13 | @protocol AACEncoderDelegate 14 | 15 | @required 16 | - (void)gotAACEncodedData:(NSData*)data timestamp:(CMTime)timestamp error:(NSError*)error; 17 | 18 | @end 19 | 20 | @interface AACEncoder : NSObject 21 | 22 | @property (weak, nonatomic) id delegate; 23 | 24 | @property (nonatomic) dispatch_queue_t encoderQueue; 25 | @property (nonatomic) dispatch_queue_t callbackQueue; 26 | 27 | - (void) encode:(CMSampleBufferRef)sampleBuffer; 28 | 29 | @end -------------------------------------------------------------------------------- /Core/Codec/H264HWDecoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // H264HWDecoder.h 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeongwook Park on 2016. 1. 5.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | // http://stackoverflow.com/questions/29525000/how-to-use-videotoolbox-to-decompress-h-264-video-stream/ 9 | 10 | #import 11 | #import 12 | 13 | @protocol H264HWDecoderDelegate 14 | 15 | - (void)displayDecodedFrame:(CVImageBufferRef)imageBuffer; 16 | 17 | @end 18 | 19 | @interface H264HWDecoder : NSObject 20 | 21 | @property (weak, nonatomic) id delegate; 22 | 23 | -(void) receivedRawVideoFrame:(uint8_t *)frame withSize:(uint32_t)frameSize isIFrame:(int)isIFrame; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Core/Codec/H264HWEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // H264HWEncoder.h 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeongwook Park on 2016. 1. 7.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | // https://github.com/manishganvir/iOS-h264Hw-Toolbox 9 | 10 | #import 11 | #import 12 | #import "H264Packet.h" 13 | 14 | @protocol H264HWEncoderDelegate 15 | 16 | @required 17 | - (void)gotH264EncodedData:(NSData *)packet timestamp:(CMTime)timestamp; 18 | 19 | @end 20 | 21 | @interface H264HWEncoder : NSObject 22 | 23 | - (void) invalidate; 24 | - (void) setOutputSize:(CGSize)size; 25 | - (void) encode:(CMSampleBufferRef )sampleBuffer; 26 | 27 | @property (weak, nonatomic) id delegate; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Core/Codec/H264Packet.h: -------------------------------------------------------------------------------- 1 | // 2 | // H264Packet.h 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeong-uk Park on 2016. 2. 25.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface H264Packet : NSObject 13 | 14 | @property (strong, nonatomic) NSMutableData *packet; 15 | 16 | - (id)initWithCMSampleBuffer:(CMSampleBufferRef)sample; 17 | 18 | - (void)packetizeAVC:(CMSampleBufferRef)sample; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Core/Codec/H264Packet.m: -------------------------------------------------------------------------------- 1 | // 2 | // H264Packet.m 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeong-uk Park on 2016. 2. 25.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import "H264Packet.h" 10 | 11 | @interface H264Packet () 12 | { 13 | } 14 | 15 | @end 16 | 17 | @implementation H264Packet 18 | 19 | - (id)initWithCMSampleBuffer:(CMSampleBufferRef)sample 20 | { 21 | self = [super init]; 22 | if(self) 23 | { 24 | [self packetizeAVC:sample]; 25 | } 26 | return self; 27 | } 28 | 29 | - (void)packetizeAVC:(CMSampleBufferRef)sample 30 | { 31 | self.packet = [NSMutableData data]; 32 | 33 | NSData *sps, *pps; 34 | 35 | CMFormatDescriptionRef format = CMSampleBufferGetFormatDescription(sample); 36 | // CFDictionaryRef extensionDict = CMFormatDescriptionGetExtensions(format); 37 | // Get the extensions 38 | // From the extensions get the dictionary with key "SampleDescriptionExtensionAtoms" 39 | // From the dict, get the value for the key "avcC" 40 | 41 | size_t sparameterSetSize, sparameterSetCount; 42 | const uint8_t *sparameterSet; 43 | OSStatus statusCode = CMVideoFormatDescriptionGetH264ParameterSetAtIndex(format, 0, &sparameterSet, &sparameterSetSize, &sparameterSetCount, 0 ); 44 | if (statusCode == noErr) 45 | { 46 | // Found sps and now check for pps 47 | size_t pparameterSetSize, pparameterSetCount; 48 | const uint8_t *pparameterSet; 49 | OSStatus statusCode = CMVideoFormatDescriptionGetH264ParameterSetAtIndex(format, 1, &pparameterSet, &pparameterSetSize, &pparameterSetCount, 0 ); 50 | if (statusCode == noErr) 51 | { 52 | // Found pps 53 | sps = [NSData dataWithBytes:sparameterSet length:sparameterSetSize]; 54 | pps = [NSData dataWithBytes:pparameterSet length:pparameterSetSize]; 55 | 56 | const char bytes[] = "\x00\x00\x00\x01"; // SPS PPS Header 57 | size_t length = (sizeof bytes) - 1; //string literals have implicit trailing '\0' 58 | NSData *byteHeader = [NSData dataWithBytes:bytes length:length]; 59 | NSMutableData *fullSPSData = [NSMutableData dataWithData:byteHeader]; 60 | NSMutableData *fullPPSData = [NSMutableData dataWithData:byteHeader]; 61 | 62 | [fullSPSData appendData:sps]; 63 | [fullPPSData appendData:pps]; 64 | 65 | sps = fullSPSData; 66 | pps = fullPPSData; 67 | } 68 | } 69 | 70 | CMBlockBufferRef dataBuffer = CMSampleBufferGetDataBuffer(sample); 71 | size_t length, totalLength; 72 | char *dataPointer; 73 | OSStatus statusCodeRet = CMBlockBufferGetDataPointer(dataBuffer, 0, &length, &totalLength, &dataPointer); 74 | if (statusCodeRet == noErr) { 75 | 76 | size_t bufferOffset = 0; 77 | static const int AVCCHeaderLength = 4; 78 | while (bufferOffset < totalLength - AVCCHeaderLength) { 79 | // Read the NAL unit length 80 | uint32_t NALUnitLength = 0; 81 | memcpy(&NALUnitLength, dataPointer + bufferOffset, AVCCHeaderLength); 82 | 83 | // Convert the length value from Big-endian to Little-endian 84 | NALUnitLength = CFSwapInt32BigToHost(NALUnitLength); 85 | 86 | NSData* data = [[NSData alloc] initWithBytes:(dataPointer + bufferOffset + AVCCHeaderLength) length:NALUnitLength]; 87 | 88 | const char bytes[] = "\x00\x00\x00\x01"; // AVC Header 89 | size_t length = (sizeof bytes) - 1; //string literals have implicit trailing '\0' 90 | NSData *byteHeader = [NSData dataWithBytes:bytes length:length]; 91 | NSMutableData *fullAVCData = [NSMutableData dataWithData:byteHeader]; 92 | 93 | [fullAVCData appendData:data]; 94 | 95 | [self.packet appendData:sps]; 96 | [self.packet appendData:pps]; 97 | [self.packet appendData:fullAVCData]; 98 | 99 | // Move to the next NAL unit in the block buffer 100 | bufferOffset += AVCCHeaderLength + NALUnitLength; 101 | } 102 | } 103 | } 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /Core/RTP/RTPClient.h: -------------------------------------------------------------------------------- 1 | // 2 | // RTPClient.h 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeongwook Park on 2016. 1. 14.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface RTPClient : NSObject 13 | 14 | @property (weak, nonatomic) NSString *address; 15 | @property (nonatomic) NSInteger port; 16 | 17 | - (void)reset; 18 | - (void)publish:(NSData *)data timestamp:(CMTime)timestamp payloadType:(NSInteger)payloadType; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Core/RTP/RTPClient.m: -------------------------------------------------------------------------------- 1 | // 2 | // TSClient.mm 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeongwook Park on 2016. 1. 14.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | // https://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol 9 | // http://stackoverflow.com/questions/17896008/can-ffmpeg-library-send-the-live-h264-ios-camera-stream-to-wowza-using-rtsp 10 | // https://github.com/goertzenator/lwip/blob/master/contrib-1.4.0/apps/rtp/rtp.c 11 | 12 | #import "RTPClient.h" 13 | #import 14 | 15 | struct rtp_header { 16 | u_int16_t v:2; /* protocol version */ 17 | u_int16_t p:1; /* padding flag */ 18 | u_int16_t x:1; /* header extension flag */ 19 | u_int16_t cc:4; /* CSRC count */ 20 | u_int16_t m:1; /* marker bit */ 21 | u_int16_t pt:7; /* payload type */ 22 | u_int16_t seq:16; /* sequence number */ 23 | u_int32_t ts; /* timestamp */ 24 | u_int32_t ssrc; /* synchronization source */ 25 | }; 26 | 27 | @interface RTPClient() 28 | { 29 | GCDAsyncUdpSocket *socket_rtp; 30 | 31 | uint16_t seqNum; 32 | 33 | dispatch_queue_t queue; 34 | 35 | uint32_t start_t; 36 | } 37 | @end 38 | 39 | @implementation RTPClient 40 | 41 | - (instancetype)init 42 | { 43 | self = [super init]; 44 | if (self) 45 | { 46 | queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0); 47 | socket_rtp = [[GCDAsyncUdpSocket alloc] init]; 48 | [socket_rtp setDelegateQueue:queue]; 49 | self.address = nil; 50 | self.port = 554; 51 | seqNum = 0; 52 | start_t = 0; 53 | } 54 | return self; 55 | } 56 | 57 | - (void)dealloc { 58 | [self reset]; 59 | [socket_rtp closeAfterSending]; 60 | } 61 | 62 | - (void)reset 63 | { 64 | start_t = 0; 65 | seqNum = 0; 66 | } 67 | 68 | #pragma mark - Publish 69 | 70 | - (void)publish:(NSData *)data timestamp:(CMTime)timestamp payloadType:(NSInteger)payloadType 71 | { 72 | int32_t t = ((float)timestamp.value / timestamp.timescale) * 1000; 73 | if(start_t == 0) start_t = t; 74 | 75 | struct rtp_header header; 76 | 77 | //fill the header array of byte with RTP header fields 78 | header.v = 2; 79 | header.p = 0; 80 | header.x = 0; 81 | header.cc = 0; 82 | header.m = 0; 83 | header.pt = payloadType; 84 | header.seq = seqNum; 85 | header.ts = t - start_t; 86 | header.ssrc = (u_int32_t)self.port; 87 | 88 | /* send RTP stream packet */ 89 | NSMutableData *packet = [NSMutableData dataWithBytes:&header length:12]; 90 | [packet appendData:data]; 91 | 92 | [socket_rtp sendData:(NSData *)packet toHost:self.address port:self.port withTimeout:-1 tag:0]; 93 | 94 | seqNum++; 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /Core/RTSP/RTSPClient.h: -------------------------------------------------------------------------------- 1 | // 2 | // RTSPClient.h 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeong-uk Park on 2016. 1. 26.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class RTSPClient; 12 | 13 | @protocol RTSPClientDelegate 14 | - (void)onRTSPDidConnectedOK:(RTSPClient *)rtsp; 15 | - (void)onRTSPDidConnectedFailed:(RTSPClient *)rtsp; 16 | - (void)onRTSPDidDisConnected:(RTSPClient *)rtsp; 17 | @optional 18 | - (void)onRTSP:(RTSPClient *)rtsp didSETUPWithServerPort:(NSNumber *)server_port; 19 | - (void)onRTSP:(RTSPClient *)rtsp didSETUP_AUDIOWithServerPort:(NSNumber *)server_port; 20 | - (void)onRTSP:(RTSPClient *)rtsp didSETUP_VIDEOWithServerPort:(NSNumber *)server_port; 21 | @end 22 | 23 | @interface RTSPClient : NSObject 24 | 25 | @property (weak, nonatomic) NSString *host; // ip address 26 | @property (weak, nonatomic) NSString *address; 27 | @property (nonatomic) NSInteger port; 28 | @property (weak, nonatomic) NSString *instance; 29 | @property (weak, nonatomic) NSString *streamName; 30 | @property (weak, nonatomic) NSString *sessionid; 31 | @property (weak, nonatomic) id delegate; 32 | 33 | - (void)connect:(NSString *)address port:(NSInteger)port instance:(NSString *)instance stream:(NSString *)stream; 34 | - (void)close; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /HLSforOSX/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // HLSforOSX 4 | // 5 | // Created by Byeong-uk Park on 2016. 2. 9.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : NSObject 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /HLSforOSX/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // HLSforOSX 4 | // 5 | // Created by Byeong-uk Park on 2016. 2. 9.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 18 | // Insert code here to initialize your application 19 | } 20 | 21 | - (void)applicationWillTerminate:(NSNotification *)aNotification { 22 | // Insert code here to tear down your application 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /HLSforOSX/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 | } -------------------------------------------------------------------------------- /HLSforOSX/CameraViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // HLSforOSX 4 | // 5 | // Created by Byeong-uk Park on 2016. 2. 9.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CameraViewController : NSViewController 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /HLSforOSX/CameraViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // HLSforOSX 4 | // 5 | // Created by Byeong-uk Park on 2016. 2. 9.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import "CameraViewController.h" 10 | #import "CameraEncoder.h" 11 | 12 | @interface CameraViewController () 13 | { 14 | CameraEncoder *encoder; 15 | bool startCalled; 16 | } 17 | @property (weak, nonatomic) IBOutlet NSButton *StartStopButton; 18 | @property (weak, nonatomic) IBOutlet NSView *preview; 19 | @end 20 | 21 | @implementation CameraViewController 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | // Do any additional setup after loading the view. 26 | 27 | encoder = [[CameraEncoder alloc] init]; 28 | 29 | [encoder initCameraWithOutputSize:CGSizeMake(640, 360)]; 30 | startCalled = true; 31 | 32 | [self.preview setWantsLayer:YES]; 33 | 34 | encoder.previewLayer.frame = self.preview.bounds; 35 | [self.preview.layer addSublayer:encoder.previewLayer]; 36 | } 37 | 38 | - (void)setRepresentedObject:(id)representedObject { 39 | [super setRepresentedObject:representedObject]; 40 | 41 | // Update the view, if already loaded. 42 | } 43 | 44 | // Called when start/stop button is pressed 45 | - (IBAction)OnStartStop:(id)sender { 46 | if (startCalled) 47 | { 48 | [encoder startCamera]; 49 | startCalled = false; 50 | [_StartStopButton setTitle:@"Stop"]; 51 | } 52 | else 53 | { 54 | [_StartStopButton setTitle:@"Start"]; 55 | startCalled = true; 56 | [encoder stopCamera]; 57 | } 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /HLSforOSX/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 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2016년 . All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /HLSforOSX/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HLSforOSX 4 | // 5 | // Created by Byeong-uk Park on 2016. 2. 9.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) { 12 | return NSApplicationMain(argc, argv); 13 | } 14 | -------------------------------------------------------------------------------- /HTTPLiveStreaming.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HTTPLiveStreaming.xcodeproj/project.xcworkspace/xcuserdata/MOBIUS.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/whiteblue3/HTTPLiveStreaming/2c991a42b114bc82890183ba96a23e6592859120/HTTPLiveStreaming.xcodeproj/project.xcworkspace/xcuserdata/MOBIUS.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /HTTPLiveStreaming.xcodeproj/xcuserdata/MOBIUS.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /HTTPLiveStreaming.xcodeproj/xcuserdata/MOBIUS.xcuserdatad/xcschemes/HLSforOSX.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /HTTPLiveStreaming.xcodeproj/xcuserdata/MOBIUS.xcuserdatad/xcschemes/HTTPLiveStreaming.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /HTTPLiveStreaming.xcodeproj/xcuserdata/MOBIUS.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | HLSforOSX.xcscheme 8 | 9 | orderHint 10 | 4 11 | 12 | HTTPLiveStreaming.xcscheme 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | A81535421C677F920085E2FC 21 | 22 | primary 23 | 24 | 25 | A81535771C6788D80085E2FC 26 | 27 | primary 28 | 29 | 30 | A87435BD1C46219B0010D438 31 | 32 | primary 33 | 34 | 35 | A8B0EFAF1C69A30C0019EB1B 36 | 37 | primary 38 | 39 | 40 | A8BCAEF91C3B49CB000229C3 41 | 42 | primary 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /HTTPLiveStreaming/AAPLPlayerView.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Apple Inc. All Rights Reserved. 3 | See LICENSE.txt for this sample’s licensing information 4 | 5 | Abstract: 6 | View containing an AVPlayerLayer. 7 | */ 8 | 9 | @import UIKit; 10 | 11 | @class AVPlayer; 12 | 13 | @interface AAPLPlayerView : UIView 14 | @property AVPlayer *player; 15 | @property (readonly) AVPlayerLayer *playerLayer; 16 | @end 17 | -------------------------------------------------------------------------------- /HTTPLiveStreaming/AAPLPlayerView.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Apple Inc. All Rights Reserved. 3 | See LICENSE.txt for this sample’s licensing information 4 | 5 | Abstract: 6 | View containing an AVPlayerLayer. 7 | */ 8 | 9 | @import Foundation; 10 | @import AVFoundation; 11 | #import "AAPLPlayerView.h" 12 | 13 | 14 | @implementation AAPLPlayerView 15 | 16 | - (AVPlayer *)player { 17 | return self.playerLayer.player; 18 | } 19 | 20 | - (void)setPlayer:(AVPlayer *)player { 21 | self.playerLayer.player = player; 22 | } 23 | 24 | // override UIView 25 | + (Class)layerClass { 26 | return [AVPlayerLayer class]; 27 | } 28 | 29 | - (AVPlayerLayer *)playerLayer { 30 | return (AVPlayerLayer *)self.layer; 31 | } 32 | 33 | @end 34 | 35 | -------------------------------------------------------------------------------- /HTTPLiveStreaming/AAPLPlayerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AAPLPlayerViewController.h 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeongwook Park on 2016. 1. 5.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class AAPLPlayerView; 13 | 14 | @interface AAPLPlayerViewController : UIViewController 15 | 16 | @property (readonly) AVQueuePlayer *player; 17 | 18 | @property CMTime currentTime; 19 | @property (readonly) CMTime duration; 20 | @property float rate; 21 | 22 | @end 23 | 24 | -------------------------------------------------------------------------------- /HTTPLiveStreaming/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeongwook Parl on 2016. 1. 5.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /HTTPLiveStreaming/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeongwook Parl on 2016. 1. 5.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /HTTPLiveStreaming/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /HTTPLiveStreaming/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /HTTPLiveStreaming/CameraViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CameraViewController.h 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeongwook Park on 2016. 1. 7.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CameraViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HTTPLiveStreaming/CameraViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CameraViewController.m 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeongwook Park on 2016. 1. 7.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import "CameraViewController.h" 10 | #import "CameraEncoder.h" 11 | 12 | @interface CameraViewController () 13 | { 14 | CameraEncoder *encoder; 15 | bool startCalled; 16 | } 17 | @property (weak, nonatomic) IBOutlet UIButton *StartStopButton; 18 | @end 19 | 20 | @implementation CameraViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | // Do any additional setup after loading the view. 25 | 26 | encoder = [[CameraEncoder alloc] init]; 27 | 28 | [encoder initCameraWithOutputSize:CGSizeMake(360, 640)]; 29 | 30 | startCalled = true; 31 | 32 | encoder.previewLayer.frame = self.view.bounds; 33 | [self.view.layer addSublayer:encoder.previewLayer]; 34 | } 35 | 36 | - (void)didReceiveMemoryWarning { 37 | [super didReceiveMemoryWarning]; 38 | // Dispose of any resources that can be recreated. 39 | } 40 | 41 | /* 42 | #pragma mark - Navigation 43 | 44 | // In a storyboard-based application, you will often want to do a little preparation before navigation 45 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 46 | // Get the new view controller using [segue destinationViewController]. 47 | // Pass the selected object to the new view controller. 48 | } 49 | */ 50 | 51 | // Called when start/stop button is pressed 52 | - (IBAction)OnStartStop:(id)sender { 53 | if (startCalled) 54 | { 55 | encoder.previewLayer.hidden = NO; 56 | [encoder startCamera]; 57 | startCalled = false; 58 | [_StartStopButton setTitle:@"Stop" forState:UIControlStateNormal]; 59 | } 60 | else 61 | { 62 | encoder.previewLayer.hidden = YES; 63 | [_StartStopButton setTitle:@"Start" forState:UIControlStateNormal]; 64 | startCalled = true; 65 | [encoder stopCamera]; 66 | } 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /HTTPLiveStreaming/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | ko_KR 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIFileSharingEnabled 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationLandscapeLeft 38 | UIInterfaceOrientationPortrait 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UISupportedInterfaceOrientations~ipad 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationPortraitUpsideDown 45 | UIInterfaceOrientationLandscapeLeft 46 | UIInterfaceOrientationLandscapeRight 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /HTTPLiveStreaming/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | 4 | Localizable strings. 5 | 6 | 7 | */ 8 | 9 | // Alert title for errors. 10 | "alert.error.title" = "Error"; 11 | 12 | // OK action on error alert 13 | "alert.error.actions.OK" = "OK"; 14 | 15 | // Queue is empty. 16 | "label.queue.empty" = "Media queue is empty"; 17 | 18 | // Queue of n item(s). 19 | "label.queue.%lu items" = "Queue of %n media items"; 20 | 21 | // Title on button to clear the queue. 22 | "button.title.clear" = "Clear Queue"; 23 | 24 | // Title of popover that clears the queue. 25 | "popover.title.clear" = "Clear"; 26 | 27 | // Message on popover that clears the queue. 28 | "popover.message.clear" = "Remove all media from the queue?"; 29 | 30 | // Title of popover cancel action. 31 | "popover.title.cancel" = "Cancel"; 32 | 33 | // Title of popover that adds items to the queue. 34 | "popover.title.addItem" = "Add Media"; 35 | 36 | // Message on popover that adds items to the queue. 37 | "popover.message.addItem" = "Select a media type to add to the queue"; 38 | 39 | // Can't use this AVAsset because one of it's keys failed to load. 40 | "error.asset_%@_key_%@_failed.description" = "Media \"%@\" failed to load key \"%@\""; 41 | 42 | // Can't use this AVAsset because it isn't playable or has protected content. 43 | "error.asset_%@_not_playable.description" = "Media \"%@\" isn't playable or has protected content"; 44 | 45 | // Failed to parse the assets manifest JSON. 46 | "error.json_parse_failed.description" = "Failed to parse the manifest"; 47 | 48 | // Failed to open the assets manifest JSON. 49 | "error.json_open_failed.description" = "Failed to open the manifest"; 50 | 51 | // Default error message when no NSError provided. 52 | "error.default.description" = "Unknown error"; 53 | -------------------------------------------------------------------------------- /HTTPLiveStreaming/en.lproj/Localizable.stringsdict: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | label.queue.%lu items 6 | 7 | NSStringLocalizedFormatKey 8 | Queue of %#@lu_items@ 9 | lu_items 10 | 11 | NSStringFormatSpecTypeKey 12 | NSStringPluralRuleType 13 | NSStringFormatValueTypeKey 14 | lu 15 | one 16 | %lu item 17 | other 18 | %lu items 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HTTPLiveStreaming/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HTTPLiveStreaming 4 | // 5 | // Created by Byeongwook Parl on 2016. 1. 5.. 6 | // Copyright © 2016년 . All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README # 2 | 3 | This project is stop the developing now. Will restart later. 4 | 5 | This project is streaming H.264/AAC using iOS Video Tool Box to encode and send packet over RTP / RTSP 6 | 7 | This project is association with Wowza Media Server 4.3 over. 8 | 9 | 10 | # Known Issue # 11 | 12 | - H264 Hardware Encoding working on iOS. Mac OS X is not working perfectly. 13 | 14 | - for Mac OS X, AVFoundation is using hardware encoding. I using it. 15 | 16 | - AAC Hardware Encoding is not working on iOS (Software Encoding). Mac OS X only (AVFoundation) 17 | 18 | - H264 Hardware Decoder is working perfectly. 19 | 20 | - H264 MaxSlice option is not working. I use packetization mode 0 (Single NAL) 21 | 22 | - H264 kVTCompressionPropertyKey_ExpectedFrameRate is not working on Mac OS X. (15 fps static only) 23 | 24 | - H264 bitrate is only working iOS. not Mac OS X. 25 | 26 | - RTSP Client is only working for stream publisher. 27 | 28 | 29 | # TODO # 30 | 31 | - MPEG4 container format support 32 | 33 | - MPEG2-TS container format support 34 | 35 | 36 | # LICENSE # 37 | 38 | This project is under GPLv2 39 | --------------------------------------------------------------------------------