/**************************************************************************
@param pChHostName: [output]Get system proxy host name
@param pChPort: [output]Get system proxy port
@param iProxyType:[input]ProxyType: 1(HTTP);2(HTTPS);....
**************************************************************************/
bool MacGetProxyHostNameAndPort(int iProxyType, char *pChHostName, char *pChPort)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; bool bRet = false;
NSDictionary *proxyConfiguration = NSMakeCollectable([(NSDictionary*) SCDynamicStoreCopyProxies(NULL) autorelease]); if (!proxyConfiguration)
{
[pool release];
return bRet;
} //Init proxy type
NSString *nsStrProxyEnable = nil;
NSString *nsStrProxyHostName = nil;
NSString *nsStrProxyPort = nil;
if ( == iProxyType)
{
nsStrProxyEnable = (NSString*)[proxyConfiguration objectForKey:@"HTTPSEnable"];
nsStrProxyHostName = (NSString*)[proxyConfiguration objectForKey:@"HTTPSProxy"];
nsStrProxyPort = [NSString stringWithFormat:@"%d", [[proxyConfiguration objectForKey:@"HTTPSPort"] intValue]];
}
else
{
nsStrProxyEnable = (NSString*)[proxyConfiguration objectForKey:@"HTTPEnable"];
nsStrProxyHostName = (NSString*)[proxyConfiguration objectForKey:@"HTTPProxy"];
nsStrProxyPort = [NSString stringWithFormat:@"%d", [[proxyConfiguration objectForKey:@"HTTPPort"] intValue]];
} int iProxyEnable = [nsStrProxyEnable intValue];
if ( == iProxyEnable)
{
const char *pHostName = [nsStrProxyHostName UTF8String];
int iLen = [nsStrProxyHostName length];
memset(pChHostName, , );
memcpy(pChHostName, pHostName, iLen); const char *pPort = [nsStrProxyPort UTF8String];
iLen = [nsStrProxyPort length];
memset(pChPort, , );
memcpy(pChPort, pPort, iLen);
bRet = true;
} [pool drain];
return bRet;
}

Get host name and port(Object-c)的更多相关文章

  1. Could not connect to SMTP host: smtp.***.com, port: 465, response: -1

    背景 在使用javamail进行邮件发送的时候,报错: Could not connect to SMTP host: smtp.***.com, port: 465, response: -1 原因 ...

  2. GitHub上传不了的解决 ssh: connect to host github.com port 22: Bad file number git did not exit cleanly (exit code 128)

    问题情况 本来一直用的是github的客户端,结果现在上传的时候出问题了,去网站上看,新项目已经创建,但是代码却怎么都上传不上去.于是只好用命令行的方式解决. Tortoisegit上是这样说的: g ...

  3. ssh: connect to host github.com port 22: Connection refused

    假设git例如,下面的问题时,远程推送: [fulinux@ubuntu learngit]$ git push -u origin master ssh: connect to host githu ...

  4. windows环境pip安装时一直报错Could not fetch URL https://pypi.org/simple/xrld/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url:

    最近项目不忙了~~有开始专研的python大业,上来想用pip安装一个第三方的库,就一直报错: Could not fetch URL https://pypi.org/simple/xrld/: T ...

  5. ssh: connect to host github.com port 22: Connection timed out

    问题描述 $ git clone git@github.com:MaugerWu/MaugerWu.github.io.git Cloning into 'MaugerWu.github.io'... ...

  6. Github拉取远端的时候提示“ssh: connect to host github.com port 22: Connection timed out”错误

    在使用Github的时候,如果使用到拉取远端分支的时候或者测试ssh -T git@github.com的时候可能会出现连接失败的问题,错误描述为“ssh: connect to host githu ...

  7. git clone遇到的[ssh: connect to host github.com port 22]

    起因 在学习递归的时候,对汉诺塔小研究了一番,参考网上写了个demo,后面就想同步到github. 过程 这台电脑是新电脑,所以需要先本地生成ssh key:ssh-keygen -t rsa -C ...

  8. github连接报"ssh: connect to host github.com port 22: Connection timed out"错误

    1. 异常 在连接github时,执行"ssh -T git@github.com" 命令时,出现 ssh: connect to host github.com port 22: ...

  9. github默认端口22被占用,ssh: connect to host github.com port 22: Connection timed out

    出现github 连接错误: ssh:connect to host github.com port 22:Connection timed out 刚开始以为是网络问题,github不能连接上,但是 ...

  10. 关于github报错:ssh: connect to host github.com port 22: Connection timed outfatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.

    当执行git命令如:git clone.git pull等等 出现报错:ssh: connect to host github.com port 22: Connection timed outfat ...

随机推荐

  1. tp5框架的获取器

    tp5的获取器功能很强大,一下子就喜欢上了,你可以在模块里任意定义表里不存在的字段,在前台调用很方便.话不多说直接上demo: 1.命名规则   get + 属性名的驼峰命名+ Attr 直接就能在m ...

  2. [javascript 实践篇]——那些你不知道的“奇淫巧技”

    1. 空(null, undefined)验证 刚开始,我是比较蠢的验证(我还真是这样子验证的) if (variable1 !== null || variable1 !== undefined | ...

  3. Servlet Filter 中init和destroy问题

    测试源码如下: package com.FilterTest.Filter; import java.io.IOException; import javax.servlet.Filter; impo ...

  4. JavaScript中闭包实现的私有属性的getter()和setter()方法

    注意: 以下的输出都在浏览器的控制台中 <!DOCTYPE html> <html> <head> <meta charset="utf-8&quo ...

  5. Android系统--输入系统(十四)Dispatcher线程情景分析_dispatch前处理

    Android系统--输入系统(十四)Dispatcher线程情景分析_dispatch前处理 1. 回顾 我们知道Android输入系统是Reader线程通过驱动程序得到上报的输入事件,还要经过处理 ...

  6. java三大框架介绍

    常听人提起三大框架,关于三大框架,做了如下了解: 三大框架:Struts+Hibernate+Spring java三大框架主要用来做WEN应用. Struts主要负责表示层的显示 Spring利用它 ...

  7. linux DNS 问题

    今天准备爬虫51job时候,发现ping不通外网了,ping 了一下IP,都是OK的,只是host不通. 呵呵,就一DNS问题,好的.第一步,开始检查配置文件 cat /etc/sysconfig/n ...

  8. Ubuntu14.04_x64_Caffe_GPU环境配置

    为了让Caffe支持GPU模式,需要安装GPU和CUDA Toolkit,依据NVIDIA官方教程以ubuntu14.04_X64安装cuda8.0,配置Gpu为例如下所示: 1.检查安装环境,是否具 ...

  9. win10下python2与python3以及pip共存

    一 分别安装python2和python3 注意: 安装时记得勾选 Add Python.exe to Path 二 安装pip Python3最新版本有pip,无需安装 Python2: 下载pip ...

  10. 51nod_1639:绑鞋带

    题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1639 #include <bits/stdc++.h& ...