码迷,mamicode.com
首页 > 其他好文 > 详细

Get host name and port(Object-c)

时间:2014-11-06 23:23:29      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:http   io   ar   os   sp   on   cti   ad   ef   

#import <SystemConfiguration/SCDynamicStoreCopySpecific.h>
#import <SystemConfiguration/SCSchemaDefinitions.h>
#import <Security/Security.h>

void GetProxyHostNameAndPort((CFStringRef proxyEnableKey, CFStringRef proxyHostNameKey, CFStringRef proxyPortKey, NSString **hostNamePtr, int *portPtr)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

//Get general proxy info
CFDictionaryRef proxyInfoCPtr = SCDynamicStoreCopyProxies(NULL);
NSDictionary *proxyInfo = (__bridge NSDictionary *) proxyInfoCPtr;
NSNumber *proxyEnabled = proxyInfo[(__bridge NSString *)proxyEnableKey];

//Check proxy enabled?
if (![proxyEnabled intValue])
{
*hostNamePtr = nil;
*portPtr = 0;

[pool release];
return;
}

*hostNamePtr = proxyInfo[(__bridge NSString *)proxyHostNameKey];
NSNumber *portNumber = proxyInfo[(__bridge NSString *)proxyPortKey];
*portPtr = [portNumber intValue];

[pool release];
return;
}

-------------------------------------------------------------
GetProxyHostNameAndPort(kSCPropNetProxiesHTTPEnable, kSCPropNetProxiesHTTPProxy, kSCPropNetProxiesHTTPPort, hostName, port);
GetProxyHostNameAndPort(kSCPropNetProxiesHTTPSEnable, kSCPropNetProxiesHTTPSProxy, kSCPropNetProxiesHTTPSPort, hostName, port);

Get host name and port(Object-c)

标签:http   io   ar   os   sp   on   cti   ad   ef   

原文地址:http://www.cnblogs.com/sz-leez/p/4080153.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!