Commit 02421f32 authored by K's avatar K
Browse files

init

parents
Showing with 624 additions and 0 deletions
+624 -0
Pod::Spec.new do |s|
s.name = 'CocoaAsyncSocket'
s.version = '7.6.5'
s.license = { :type => 'public domain', :text => <<-LICENSE
Public Domain License
The CocoaAsyncSocket project is in the public domain.
The original TCP version (AsyncSocket) was created by Dustin Voss in January 2003.
Updated and maintained by Deusty LLC and the Apple development community.
LICENSE
}
s.summary = 'Asynchronous socket networking library for Mac and iOS.'
s.homepage = 'https://github.com/robbiehanson/CocoaAsyncSocket'
s.authors = 'Dustin Voss', { 'Robbie Hanson' => 'robbiehanson@deusty.com' }
s.source = { :git => 'https://github.com/robbiehanson/CocoaAsyncSocket.git',
:tag => "#{s.version}" }
s.description = 'CocoaAsyncSocket supports TCP and UDP. The AsyncSocket class is for TCP, and the AsyncUdpSocket class is for UDP. ' \
'AsyncSocket is a TCP/IP socket networking library that wraps CFSocket and CFStream. It offers asynchronous ' \
'operation, and a native Cocoa class complete with delegate support or use the GCD variant GCDAsyncSocket. ' \
'AsyncUdpSocket is a UDP/IP socket networking library that wraps CFSocket. It works almost exactly like the TCP ' \
'version, but is designed specifically for UDP. This includes queued non-blocking send/receive operations, full ' \
'delegate support, run-loop based, self-contained class, and support for IPv4 and IPv6.'
s.source_files = 'Source/GCD/*.{h,m}'
s.requires_arc = true
s.ios.deployment_target = '9.0'
s.tvos.deployment_target = '9.0'
s.osx.deployment_target = '10.8'
s.ios.frameworks = 'CFNetwork', 'Security'
s.tvos.frameworks = 'CFNetwork', 'Security'
s.osx.frameworks = 'CoreServices', 'Security'
end
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:CocoaAsyncSocket.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9FC41F121B9D965000578BEB"
BuildableName = "CocoaAsyncSocket.framework"
BlueprintName = "Mac CocoaAsyncSocket"
ReferencedContainer = "container:CocoaAsyncSocket.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9FC41F1C1B9D965000578BEB"
BuildableName = "Mac CocoaAsyncSocketTests.xctest"
BlueprintName = "Mac CocoaAsyncSocketTests"
ReferencedContainer = "container:CocoaAsyncSocket.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9FC41F121B9D965000578BEB"
BuildableName = "CocoaAsyncSocket.framework"
BlueprintName = "Mac CocoaAsyncSocket"
ReferencedContainer = "container:CocoaAsyncSocket.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9FC41F1C1B9D965000578BEB"
BuildableName = "Mac CocoaAsyncSocketTests.xctest"
BlueprintName = "Mac CocoaAsyncSocketTests"
ReferencedContainer = "container:CocoaAsyncSocket.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9FC41F121B9D965000578BEB"
BuildableName = "CocoaAsyncSocket.framework"
BlueprintName = "Mac CocoaAsyncSocket"
ReferencedContainer = "container:CocoaAsyncSocket.xcodeproj">
</BuildableReference>
</MacroExpansion>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9FC41F121B9D965000578BEB"
BuildableName = "CocoaAsyncSocket.framework"
BlueprintName = "Mac CocoaAsyncSocket"
ReferencedContainer = "container:CocoaAsyncSocket.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6CD9900F1B77868C0011A685"
BuildableName = "CocoaAsyncSocket.framework"
BlueprintName = "iOS CocoaAsyncSocket"
ReferencedContainer = "container:CocoaAsyncSocket.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6CD9900F1B77868C0011A685"
BuildableName = "CocoaAsyncSocket.framework"
BlueprintName = "iOS CocoaAsyncSocket"
ReferencedContainer = "container:CocoaAsyncSocket.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6CD990191B77868C0011A685"
BuildableName = "CocoaAsyncSocketTests.xctest"
BlueprintName = "CocoaAsyncSocketTests"
ReferencedContainer = "container:CocoaAsyncSocket.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6CD9900F1B77868C0011A685"
BuildableName = "CocoaAsyncSocket.framework"
BlueprintName = "iOS CocoaAsyncSocket"
ReferencedContainer = "container:CocoaAsyncSocket.xcodeproj">
</BuildableReference>
</MacroExpansion>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6CD9900F1B77868C0011A685"
BuildableName = "CocoaAsyncSocket.framework"
BlueprintName = "iOS CocoaAsyncSocket"
ReferencedContainer = "container:CocoaAsyncSocket.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7D8B70C31BCFA15700D8E273"
BuildableName = "CocoaAsyncSocket.framework"
BlueprintName = "tvOS CocoaAsyncSocket"
ReferencedContainer = "container:CocoaAsyncSocket.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7D8B70C31BCFA15700D8E273"
BuildableName = "CocoaAsyncSocket.framework"
BlueprintName = "tvOS CocoaAsyncSocket"
ReferencedContainer = "container:CocoaAsyncSocket.xcodeproj">
</BuildableReference>
</MacroExpansion>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7D8B70C31BCFA15700D8E273"
BuildableName = "CocoaAsyncSocket.framework"
BlueprintName = "tvOS CocoaAsyncSocket"
ReferencedContainer = "container:CocoaAsyncSocket.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:BonjourClient.xcodeproj">
</FileRef>
</Workspace>
#import <Cocoa/Cocoa.h>
@class GCDAsyncSocket;
@interface BonjourClientAppDelegate : NSObject <NSApplicationDelegate, NSNetServiceBrowserDelegate, NSNetServiceDelegate>
{
NSNetServiceBrowser *netServiceBrowser;
NSNetService *serverService;
NSMutableArray *serverAddresses;
GCDAsyncSocket *asyncSocket;
BOOL connected;
NSWindow *__unsafe_unretained window;
}
@property (unsafe_unretained) IBOutlet NSWindow *window;
@end
#import "BonjourClientAppDelegate.h"
#import "GCDAsyncSocket.h"
#import "DDLog.h"
#import "DDTTYLogger.h"
#import "DDASLLogger.h"
// Log levels: off, error, warn, info, verbose
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
@interface BonjourClientAppDelegate (Private)
- (void)connectToNextAddress;
@end
#pragma mark -
@implementation BonjourClientAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Configure logging framework
[DDLog addLogger:[DDTTYLogger sharedInstance]];
[DDLog addLogger:[DDASLLogger sharedInstance]];
// Start browsing for bonjour services
netServiceBrowser = [[NSNetServiceBrowser alloc] init];
[netServiceBrowser setDelegate:self];
[netServiceBrowser searchForServicesOfType:@"_YourServiceName._tcp." inDomain:@"local."];
}
- (void)netServiceBrowser:(NSNetServiceBrowser *)sender didNotSearch:(NSDictionary *)errorInfo
{
DDLogError(@"DidNotSearch: %@", errorInfo);
}
- (void)netServiceBrowser:(NSNetServiceBrowser *)sender
didFindService:(NSNetService *)netService
moreComing:(BOOL)moreServicesComing
{
DDLogVerbose(@"DidFindService: %@", [netService name]);
// Connect to the first service we find
if (serverService == nil)
{
DDLogVerbose(@"Resolving...");
serverService = netService;
[serverService setDelegate:self];
[serverService resolveWithTimeout:5.0];
}
}
- (void)netServiceBrowser:(NSNetServiceBrowser *)sender
didRemoveService:(NSNetService *)netService
moreComing:(BOOL)moreServicesComing
{
DDLogVerbose(@"DidRemoveService: %@", [netService name]);
}
- (void)netServiceBrowserDidStopSearch:(NSNetServiceBrowser *)sender
{
DDLogInfo(@"DidStopSearch");
}
- (void)netService:(NSNetService *)sender didNotResolve:(NSDictionary *)errorDict
{
DDLogError(@"DidNotResolve");
}
- (void)netServiceDidResolveAddress:(NSNetService *)sender
{
DDLogInfo(@"DidResolve: %@", [sender addresses]);
if (serverAddresses == nil)
{
serverAddresses = [[sender addresses] mutableCopy];
}
if (asyncSocket == nil)
{
asyncSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
[self connectToNextAddress];
}
}
- (void)connectToNextAddress
{
BOOL done = NO;
while (!done && ([serverAddresses count] > 0))
{
NSData *addr;
// Note: The serverAddresses array probably contains both IPv4 and IPv6 addresses.
//
// If your server is also using GCDAsyncSocket then you don't have to worry about it,
// as the socket automatically handles both protocols for you transparently.
if (YES) // Iterate forwards
{
addr = [serverAddresses objectAtIndex:0];
[serverAddresses removeObjectAtIndex:0];
}
else // Iterate backwards
{
addr = [serverAddresses lastObject];
[serverAddresses removeLastObject];
}
DDLogVerbose(@"Attempting connection to %@", addr);
NSError *err = nil;
if ([asyncSocket connectToAddress:addr error:&err])
{
done = YES;
}
else
{
DDLogWarn(@"Unable to connect: %@", err);
}
}
if (!done)
{
DDLogWarn(@"Unable to connect to any resolved address");
}
}
- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port
{
DDLogInfo(@"Socket:DidConnectToHost: %@ Port: %hu", host, port);
connected = YES;
}
- (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err
{
DDLogWarn(@"SocketDidDisconnect:WithError: %@", err);
if (!connected)
{
[self connectToNextAddress];
}
}
@end
//
// Prefix header for all source files of the 'BonjourClient' target in the 'BonjourClient' project
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif
/* Localized versions of Info.plist keys */
This diff is collapsed.
//
// main.m
// BonjourClient
//
// Created by Robbie Hanson on 1/27/11.
// Copyright 2011 Voalte. All rights reserved.
//
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **) argv);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:BonjourServer.xcodeproj">
</FileRef>
</Workspace>
#import <Cocoa/Cocoa.h>
@class GCDAsyncSocket;
@interface BonjourServerAppDelegate : NSObject <NSApplicationDelegate, NSNetServiceDelegate>
{
NSNetService *netService;
GCDAsyncSocket *asyncSocket;
NSMutableArray *connectedSockets;
NSWindow *__unsafe_unretained window;
}
@property (unsafe_unretained) IBOutlet NSWindow *window;
@end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment