libcurl 进行HTTPS进行双向认证返回CURLE_SSL_CONNECT_ERROR失败

最近公司项目需要SSL双向认证,我就用libcurl来实现,但是在做Demo的时候请求是没问题的,可是吧代码放到主程序(windows下 Unicode字符集)里面,返回的总是 CURLE_SSL_CONNECT_ERROR不知道是哪里出问题了,下面是源码
int CUrlHttp::Request(std::string strRequestType,
std::string strUrl,
std::string &strReport,
std::string &strRetHeader,
std::vectorstd::string vecHeader,
std::string strParam/* ="" /,
std::string strCookie/
="" /,
std::string strCaPath/
="" /,
int nTimeOut/
=0 */)
{
strUrl = "https://192.168.5.176:4433/ipass00/http/localhost/welcome";
CURL * curl;
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());

if ( strRequestType.compare("post")==0 || strRequestType.compare("POST") == 0 )
{
    curl_easy_setopt(curl, CURLOPT_POST, 1);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(strParam.c_str()));//post内容长度
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, strParam.c_str());
}
else
{
    curl_easy_setopt(curl, CURLOPT_POST, 0);//get请求
}

//设置http头
curl_slist * headers = NULL;
for ( int i=0; i<vecHeader.size(); i++ )
{
    if (!vecHeader.at(i).empty())
    {
        headers = curl_slist_append(headers, vecHeader.at(i).c_str());
    }
}
if (headers != NULL)
{
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
}

curl_easy_setopt(curl,CURLOPT_SSLVERSION,1);

//判断是否有证书
if(!strCaPath.empty())
{
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
}
else
{
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true);
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, true);
    curl_easy_setopt(curl,CURLOPT_CAINFO,"C:/ssl/cacert.pem");

    curl_easy_setopt(curl,CURLOPT_SSLCERT,"C:/ssl/client.pem");  
    curl_easy_setopt(curl,CURLOPT_SSLCERTPASSWD,"11111111");  
    curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");  
    curl_easy_setopt(curl,CURLOPT_SSLKEY,"C:/ssl/clientkey.pem");  
    curl_easy_setopt(curl,CURLOPT_SSLKEYPASSWD,"11111111");  
    curl_easy_setopt(curl,CURLOPT_SSLKEYTYPE,"PEM");


}

//Web服务器一般会重定向链接,比如访问http:/xxx/x1.do自动转到http:/xxx/x2.do  
//所以一定要设置CURLOPT_FOLLOWLOCATION为1,否则重定向后的数据不会返回。  
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION,1); 

curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);     //可以看到调试信息

curl_easy_setopt(curl,CURLOPT_HEADERFUNCTION,_CURL_::write_data);
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, &strRetHeader);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _CURL_::write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &strReport); 
if ( nTimeOut > 0  )
{
    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, nTimeOut);
    curl_easy_setopt(curl, CURLOPT_TIMEOUT, nTimeOut);
}

if (!strCookie.empty())
{

    curl_easy_setopt(curl, CURLOPT_COOKIEFILE, strCookie.c_str());
}

CURLcode code = curl_easy_perform(curl);
if(code != CURLE_OK){  

    printf("curl_wasy_perform error = %s",curl_easy_strerror(code));  
}  
if ( headers != NULL )
{
    curl_slist_free_all(headers);
}
curl_easy_cleanup(curl);
//打印出来

// std::string strReportData;
// strReportData.append(strReportHeader);
// strReportData.append(strReport);
// TRACE("request:%s url:%s report:%s", strRequestType.c_str(), strUrl.c_str(), strReportData.c_str());
return code;
}

3个回答

无奈自己结帖,其实原因很简单,项目中之前用到过libcurl,之前的版本和现在的版本冲突了才导致请求不成功

虚心求教,还望大神不吝赐教

看看是不是什么字符是Unicode定位。而你定位程序应该都是处理的单字节字符串

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
PHP exec()curl返回errno 18(CURLE_PARTIAL_FILE)

<div class="post-text" itemprop="text"> <p>When I use the shell command <code>curl</code> from PHP to grab a zip format file, it returns errno 18.</p> <p>I retried 3 times, it always returns errno 18.</p> <p>Code:</p> <pre><code> $shell = "curl \"{$url}\" -k -o {$localfile} "; exec($shell, $outPut, $rVal); </code></pre> <p>The return value, <code>$rVal</code>, always equals 18 (<code>CURLE_PARTIAL_FILE</code>).</p> <p>Someone said <code>CURLE_PARTIAL_FILE</code> means that the transfer was aborted before the full contents arrived.</p> <p>I wonder if it should return errno 28 instead [Operation timeout. The specified time-out period was reached according to the conditions.]?</p> <p>Can anyone help me?</p> </div>

C++调用CURL下载文件暂停后恢复下载失败。错误码CURLE_PARTIAL_FILE。

C++调用CURL下载文件暂停后恢复下载失败。错误码CURLE_PARTIAL_FILE。 暂停一分钟内恢复下载没有问题,但是在暂停超过两分钟恢复下载的时候就会出现CURLE_PARTIAL_FILE。 开始以为是DNS在内存中保存超时了,结果调用了CURLOPT_DNS_CACHE_TIMEOUT还是不行。 GOOGLE了一把,有人遇到这个问题,但是没有看到具体的解决方案。 ``` curl_easy_pause(m_pCurl, CURLPAUSE_RECV); ///暂停下载 curl_easy_pause(m_pCurl, CURLPAUSE_RECV_CONT);///恢复下载 ``` 在线等,求大神给指点迷津,感激不尽。。。。

当尝试使用代理打开URL时,CURLE_RECV_ERROR 56

<div class="post-text" itemprop="text"> <p>I have been trying to send curl requests with a proxy. When I send such requests with a POST method, it works fine, but it doesn't work with GET method and I get:</p> <blockquote> <p>CURLE_RECV_ERROR (56) - Failure when receiving data from the peer.</p> </blockquote> <p>Any possible reason why that occurs?</p> <p>The below code returns this error whereas when I execute it with another url using POST METHOD it works fine.</p> <pre><code>$handle = curl_init($url); curl_setopt($handle, CURLOPT_POST , 0); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); curl_setopt($handle, CURLOPT_HEADER , 1); curl_setopt($handle, CURLOPT_MAXREDIRS , 5); curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true); curl_setopt($handle, CURLOPT_USERAGENT , 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.4) Gecko/20091016 Firefox/3.5.4'); // curl_setopt($handle, CURLOPT_POSTFIELDS , "gender=M"); curl_setopt($handle,CURLOPT_PROXY , $proxyUrl); curl_setopt($handle,CURLOPT_PROXYUSERPWD , $urlProxyUserPwd); echo curl_exec($handle); </code></pre> </div>

libcurl是如何区分单向认证和双向认证的?

话不多说,直奔主题: curl_easy_setopt(m_curl_handler, CURLOPT_SSL_VERIFYPEER, 1); curl_easy_setopt(m_curl_handler, CURLOPT_SSL_VERIFYHOST, 2); 这两行是进行校验证书的, 我想问的是:libcurl是如何区分单向认证和双向认证的? 我理解是VERIFYPEER是用来校验证书的,HOST只是用来检验连接的url 是不是再证书中列举出来了。也不知道理解的对不对,看了官网没理解透彻。 但是只有VERIFYPEER怎么区分啊!!!!!!!!!

如何在使用sftp上传文件时修复PHP curl错误CURLE_SSH(79)

<div class="post-text" itemprop="text"> <p>I'm trying to reproduce the following command to upload a file via sftp on my PHP app:</p> <pre><code>curl -T /var/repo/file -u user:password sftp://server.com/folder/ </code></pre> <p>The above commands works just fine (I had to recompile libcurl on my ubuntu box in order to make it work, though). However, when I tried to use PHP's curl library, things didn't go so well for me.</p> <p>The code I'm using is the following:</p> <pre><code>$ch = curl_init(); $localfile = 'file'; $fp = fopen($localfile, 'r'); curl_setopt($ch, CURLOPT_URL, 'sftp://server.com/folder/'); curl_setopt($ch, CURLOPT_UPLOAD, 1); curl_setopt($ch, CURLOPT_USERPWD, 'user:password'); curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_SFTP); curl_setopt($ch, CURLOPT_INFILE, $fp); curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_exec ($ch); $error_no = curl_errno($ch); curl_close ($ch); if ($error_no == 0) { $error = 'File uploaded succesfully.'; } else { $error = 'File upload error.'; } echo $error.' '.$error_no; </code></pre> <p>This gives back error 79: CURLE_SSH (79) which I dont know how to fix. Have you faced this problem? How did you fix it? Any ideas?</p> <p>Thanks!</p> </div>

libcurl 如何以 CURLAUTH_DIGEST 方式通过认证

libcurl 以 CURLAUTH_DIGEST 方式无法通过认证。如下图所示: ![图片说明](https://img-ask.csdn.net/upload/201903/07/1551953669_580097.jpg) 如果以CURLAUTH_BASIC方式,并且服务端也改为basic认证,可以通过,如下图所示: ![图片说明](https://img-ask.csdn.net/upload/201903/07/1551953912_259786.png) libcurl接口代码如下: ![图片说明](https://img-ask.csdn.net/upload/201903/07/1551954091_436060.png) 看CURLAUTH_DIGEST 过程还需要realm,nonce,response,不知道代码改如何写?

cURL错误:无法连接:已禁用SSL。 错误号码35

<div class="post-text" itemprop="text"> <p>I am working on the paypal ipn script in one of my applications hosted on a Digital Ocean's box with Centos 7. </p> <p>When i try to connect to the paypal sandbox api i get the error "Cannot connect: SSL is disabled."</p> <p>I have tried several things like adding the path of the curl.cainfo in my php.ini file like so<br> <code>curl.cainfo = /etc/pki/tls/certs/ca-bundle.trust.crt</code></p> <p>this is what my cURL script looks like</p> <pre><code>// STEP 2: Post IPN data back to paypal to validate $ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr'); // change to [...]sandbox.paypal[...] when using sandbox to test curl_setopt($ch, CURLOPT_SSLVERSION, 4); curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'ecdhe_rsa_aes_128_gcm_sha_256'); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close')); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); </code></pre> <p>I have not got much experience with Linux server setup so I am learning as i go along. Any help or guide is much appreciated</p> <p>UPDATE : when i run the this command in the command line <code>curl --version https://sandbox.paypal.com/cgi-bin/webscr</code></p> <p>i get this error <code>curl: (1) Protocol "https" not supported or disabled in libcurl</code></p> <p>Also the command <code>curl --version</code> displays <code>curl 7.42.1 (x86_64-unknown-linux-gnu) libcurl/7.46.0</code></p> <p>So i am guessing the new question would be how to enable https in libcurl?</p> </div>

Facebook SSL3_READ_BYTES:sslv3警报握手失败

<div class="post-text" itemprop="text"> <p>I am trying to connect with Facebook For Login, but I do not know why I am getting errors. Below is the curl code that I am using:</p> <pre><code> $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_SSLVERSION, 3); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false); curl_setopt($ch,CURLOPT_CAINFO, getcwd().'/cacert.pem'); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"); $result = curl_exec($ch); </code></pre> <p>but still I am getting below error :</p> <pre><code>error: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure </code></pre> <p>My server is Centos 6.5 with PHP 5.4 with below Curl Version :</p> <blockquote> <p>curl 7.44.0 (x86_64-redhat-linux-gnu) libcurl/7.44.0 OpenSSL/1.0.1e zlib/1.2.3 c-ares/1.10.0 libidn/1.18 libssh2/1.6.0</p> <p>Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp</p> <p>Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets Metalink</p> </blockquote> </div>

求大神指教libcurl问题:使用ssh登录服务器时报错了。

刚接触libcurl,菜鸟一个。我的libcurl的版本是: curl 7.42.1 (x86_64-unknown-linux-gnu) libcurl/7.42.1 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 libssh2/1.4.3 librtmp/2.3 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP UnixSockets 然后我用命令:curl -u username sftp://123.123.123.123 回车后输入密码后就出现了以下错误: curl: (51) SSL peer certificate or SSH remote key was not OK。 纠结了两天了,求大神指导!

封装的libcurl类在使用vector时出错

环境: 系统:Windows 8专业版(32位) IDE:VS 2013 curl库版本:libcurl-7.19.3-win32-ssl-msvc 运行时提示 > 0x61DE35F7 (curllib.dll) (curltest.exe 中)处有未经处理的异常: 0xC0000005: 读取位置 0xFEEEFF02 时发生访问冲突。 #include "stdafx.h" #include "curl/curl.h" #include <iostream> #include <fstream> #include <sstream> #include <string> #include <vector> #include <io.h> #pragma comment(lib, "curl/libcurl_imp.lib") #define PROGNAME "curltest" #define RETRY_TIME 5 #define URL_SIZE 100 using namespace std; size_t print_callback(char* buffer, size_t size, size_t nitems, void *outstream) { return nitems; } size_t write_callback(char* buffer, size_t size, size_t nitems, string &text) { size_t sizes = size * nitems; string temp(buffer, sizes); text += temp; return sizes; } int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) { printf("%.1f%%\t", 100 * (dlnow / dltotal)); cout << "\r"; cout.flush(); return 0; } class Novel { private: CURL *eh; CURLcode res; int http_code; int retry_time; public: int id; double filesize; bool is_exist; char *url = new char[URL_SIZE]; string *text = new string; Novel(int id) { this->id = id; retry_time = RETRY_TIME; sprintf_s(url, URL_SIZE, "dl.wenku8.cn/down.php?type=txt&id=%d", id); eh = curl_easy_init(); curl_easy_setopt(eh, CURLOPT_URL, url); curl_easy_setopt(eh, CURLOPT_WRITEFUNCTION, print_callback); curl_easy_setopt(eh, CURLOPT_NOPROGRESS, 1); curl_easy_setopt(eh, CURLOPT_PROGRESSFUNCTION, progress_callback); curl_easy_setopt(eh, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(eh, CURLOPT_HEADER, 1); curl_easy_setopt(eh, CURLOPT_NOBODY, 1); res = curl_easy_perform(eh); curl_easy_getinfo(eh, CURLINFO_HTTP_CODE, &http_code); if (http_code == 404) { is_exist = false; filesize = -1; return; } else is_exist = true; curl_easy_getinfo(eh, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &filesize); } int start() { if (is_exist == false) { cerr << "文件不存在" << endl; return 1; } else { curl_easy_setopt(eh, CURLOPT_WRITEFUNCTION, write_callback); curl_easy_setopt(eh, CURLOPT_NOBODY, 0); curl_easy_setopt(eh, CURLOPT_HEADER, 0); curl_easy_setopt(eh, CURLOPT_NOPROGRESS, 0); curl_easy_setopt(eh, CURLOPT_WRITEDATA, text); cout << "正在下载 " << id << ".txt" << endl; res = curl_easy_perform(eh); if (res != CURLE_OK) { cerr << curl_easy_strerror(res) << endl; return -1; } cout << "下载完成" << endl; } return 0; } ~Novel() { curl_easy_cleanup(eh); delete[] url; delete text; } }; int main(int argc, char *argv[]) { /* int retry_time = RETRY_TIME; int id = 1; vector<Novel> vNovel; for (id = 1; retry_time!=0; id++) { vNovel.push_back(id); if (vNovel[id - 1].start()) { retry_time--; } else { retry_time = RETRY_TIME; } } getchar(); vNovel.clear(); // 这句出错 */ // 上面是出错的地方,下面无错 Novel test(1); test.start(); getchar(); return 0; }

linux下libcurl异步收发问题

最近在使用libcurl异步收发消息时碰到一个问题,实在没头绪,有哪位大大可以帮忙看看,多谢 一、目标:使用multi interface实现消息异步收发,两个线程,一个线程发消息,另一个线程收消息 二、问题: 1、环回收发无问题,但是发送到其它IP有问题,抓包能建立TCP连接,但是马上会断开,没有发出数据 2、程序会发生段错误具体信息如下 ``` (gdb) bt #0 0x0000003d0e432222 in curl_multi_fdset (multi_handle=0x604120, read_fd_set=0x7ffff7fd4d00, write_fd_set=0x0, exc_fd_set=<value optimized out>, max_fd=0x7ffff7fd4bfc) at multi.c:874 #1 0x0000000000400d08 in curl_multi_select (curl_m=0x604120) at curl_send.c:30 #2 0x0000000000400fb3 in curl_multi_recv () at curl_send.c:110 #3 0x0000003cf84079d1 in start_thread () from /lib64/libpthread.so.0 #4 0x0000003cf80e88fd in clone () from /lib64/libc.so.6 (gdb) f 0 #0 0x0000003d0e432222 in curl_multi_fdset (multi_handle=0x604120, read_fd_set=0x7ffff7fd4d00, write_fd_set=0x0, exc_fd_set=<value optimized out>, max_fd=0x7ffff7fd4bfc) at multi.c:874 874 in multi.c (gdb) f 1 #1 0x0000000000400d08 in curl_multi_select (curl_m=0x604120) at curl_send.c:30 30 curl_multi_fdset(curl_m, &fd_read, NULL, NULL, &max_fd); (gdb) ``` 三、代码 ``` #include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <curl/curl.h> CURLM *g_curl_m = NULL; int curl_multi_select(CURLM *curl_m) { int ret = 0; struct timeval timeout_tv; fd_set fd_read; fd_set fd_write; fd_set fd_except; int max_fd = -1; if (NULL == curl_m) { return -1; } FD_ZERO(&fd_read); FD_ZERO(&fd_write); FD_ZERO(&fd_except); timeout_tv.tv_sec = 1; timeout_tv.tv_usec = 0; curl_multi_fdset(curl_m, &fd_read, NULL, NULL, &max_fd); if (-1 == max_fd) { return -1; } int select_ret = select(max_fd + 1, &fd_read, NULL, NULL, &timeout_tv); if (-1 == select_ret) { ret = -1; } else { ret = 0; } return ret; } size_t save_response(void *buffer, size_t size, size_t nmemb, void *userp) { static int recv_times = 0; recv_times++; printf("recv response:\n%d\n", recv_times); printf("%s\n", buffer); return size * nmemb; } void curl_multi_send() { int send_times = 0; int running_handle_count = 0; char auth[32] = {0}; while(1) { CURL *easy_handle = NULL; struct curl_slist *http_header = NULL; send_times++; memset(auth, 0, sizeof(auth)); easy_handle = curl_easy_init(); snprintf(auth, sizeof(auth), "Authorization:%d", send_times); http_header = curl_slist_append(http_header, auth); http_header = curl_slist_append(http_header, "User-Agent: freecwmp"); http_header = curl_slist_append(http_header, "Content-Type: text/xml"); http_header = curl_slist_append(http_header, "Expect:"); curl_easy_setopt(easy_handle, CURLOPT_URL, "http://guest:guest@10.55.0.156:9000/"); curl_easy_setopt(easy_handle, CURLOPT_HTTPHEADER, http_header); curl_easy_setopt(easy_handle, CURLOPT_POSTFIELDS, ""); curl_easy_setopt(easy_handle, CURLOPT_WRITEFUNCTION, save_response); curl_multi_add_handle(g_curl_m, easy_handle); while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(g_curl_m, &running_handle_count)) { } printf("Success send http msg.\n"); usleep(10000000); } return; } void curl_multi_recv() { int msgs_left = 0; int running_handles = 0; CURLM *curl_m = NULL; CURLMsg *msg = NULL; curl_m = g_curl_m; while(1) { if (0 == curl_multi_select(curl_m)) { msgs_left = 0; running_handles = 0; while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(curl_m, &running_handles)) { } while ((msg = curl_multi_info_read(curl_m, &msgs_left))) { if (CURLMSG_DONE == msg->msg) { curl_multi_remove_handle(curl_m, msg->easy_handle); } } } usleep(100000); } return; } int main(int argc, char *argv[]) { curl_global_init(CURL_GLOBAL_ALL); g_curl_m = curl_multi_init(); pthread_t send_pid = {0}; pthread_t receive_pid = {0}; //pthread_attr_t attr = {0}; //pthread_attr_init(&attr); //pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&receive_pid, NULL, (void *) curl_multi_recv, NULL); pthread_create(&send_pid, NULL, (void *) curl_multi_send, NULL); //pthread_attr_destroy(&attr); pthread_join(send_pid, NULL); pthread_join(receive_pid, NULL); curl_global_cleanup(); return 0; } ```

https开始使用libcurl vs golang

<div class="post-text" itemprop="text"> <p>Say, I've a list of urls: </p> <pre><code>$ for i in `seq 1 90`; do echo "$RANDOM$RANDOM.blogspot.com" ; done &gt;&gt; /tmp/urls.txt </code></pre> <p>My GETs in C takes much longer than when using my go code. </p> <p>Here's the C code:</p> <p><strong>n_memory.c</strong></p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;curl/curl.h&gt; struct MemoryStruct { char *memory; size_t size; }; static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; struct MemoryStruct *mem = (struct MemoryStruct *)userp; char *ptr = realloc(mem-&gt;memory, mem-&gt;size + realsize + 1); if(ptr == NULL) { printf("not enough memory (realloc returned NULL) "); return 0; } mem-&gt;memory = ptr; memcpy(&amp;(mem-&gt;memory[mem-&gt;size]), contents, realsize); mem-&gt;size += realsize; mem-&gt;memory[mem-&gt;size] = 0; return realsize; } int try_url(char *url); int main(int argc, char **argv){ if (argc &lt; 2){ fprintf(stderr, "error, argc "); return 1; } FILE *fp = fopen(argv[1],"r"); if (!fp){ fprintf(stderr, "fopen, argc "); return 1; } int count = 1; char _line[2048]; char url[8192]; while ( fgets(_line, 1024, fp) ){ _line[strcspn(_line, " ")] = 0; char *part1 = "https://dns.google.com/resolve?name="; char *part3 = "&amp;type=A"; snprintf(url, 4096, "%s%s%s", part1, _line, part3); printf("%d %s ", count, url); try_url(url); if (count &gt; 80){ break; } count++; } //try_url(argv[1]); puts("Done"); return 0; } int try_url(char *url) { CURL *hnd; CURLcode res; struct curl_slist *slist1; struct MemoryStruct chunk; chunk.memory = malloc(1); /* will be grown as needed by the realloc above */ chunk.size = 0; /* no data at this point */ curl_global_init(CURL_GLOBAL_ALL); hnd = curl_easy_init(); curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); curl_easy_setopt(hnd, CURLOPT_HTTP_VERSION, (long)CURL_HTTP_VERSION_2TLS); curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); curl_easy_setopt(hnd, CURLOPT_RESOLVE, slist1); slist1 = NULL; slist1 = curl_slist_append(slist1, "dns.google.com:443:172.217.5.110"); curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYHOST, 0); curl_easy_setopt(hnd, CURLOPT_URL, url); curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); curl_easy_setopt(hnd, CURLOPT_WRITEDATA, (void *)&amp;chunk); curl_easy_setopt(hnd, CURLOPT_USERAGENT, "libcurl-agent/1.0"); res = curl_easy_perform(hnd); if(res != CURLE_OK) { fprintf(stderr, "curl_easy_perform() failed: %s ", curl_easy_strerror(res)); } else { printf("%lu bytes retrieved ", (unsigned long)chunk.size); } curl_easy_cleanup(hnd); free(chunk.memory); curl_global_cleanup(); return 0; } </code></pre> <p>and here's the go code:</p> <p><strong>n_get.go</strong></p> <pre><code>package main import ( "bufio" "fmt" "log" "net/http" "os" "time" ) func main() { if len(os.Args) &lt; 2 { fmt.Println("Invalid usage") os.Exit(1) } filename := os.Args[1] f, err := os.Open(filename) checkerr(err) defer f.Close() fscanner := bufio.NewScanner(f) i := 1 for fscanner.Scan() { text := fscanner.Text() // https://dns.google.com/resolve?name=1.bp.blogspot.com&amp;type=A url := "https://dns.google.com/resolve?name=" + text + "&amp;type=A" //fmt.Println(i, url); get_url(url) if i == 80 { break } i = i + 1 } fmt.Println("Hello!") } func checkerr(err error) { if err != nil { fmt.Println(err) log.Fatal(err) } } func get_url(url string) int { fmt.Println(url) t1 := time.Now() resp, err := http.Get(url) t2 := time.Now() checkerr(err) fmt.Println(resp.Status) diff := t2.Sub(t1) fmt.Println(url, "Took us", diff) if resp.StatusCode == 200 { fmt.Println("OK") return 0 } else { fmt.Println("Failed") return 1 } } </code></pre> <p>I even tried to assist libcurl with a --resolve option to pass in an IP address it can use, thus saving it from having to do name lookups. However this does not seem to help much. </p> <p>Even tried a <code>--insecure</code> option with curl, still does not make much of a dent. </p> <p>Here's the time it took to do 80 HTTPS GETs:</p> <pre><code>+------------------+-----------------+ | golang | c | +------------------------------------+ | real 0m2.670s |real 0m20.024s| | user 0m0.555s |user 0m13.393s| | sys 0m0.086s |sys 0m0.242s | +------------------------------------+ </code></pre> <p>This is a bit lopsided, and I am looking for pointers to close the gap. How can I improve my C code's speed? Any points would be much appreciated. </p> </div>

Curl make的时候报错,求大佬指点迷津

因为默认的curl不支持https协议,我编译安装完openssl之后显示已支持https了,但是在重新make curl时出现报错。 求大佬指点迷津。 ``` curl版本:7.57 openssl版本:1.1.0g ubuntu版本:14.04.2 LTS ``` 详细报错信息如下: ``` root@iZwz9akk7iswd53zv5vrzeZ:~/curl-7.57.0# make Making all in lib make[1]: Entering directory `/root/curl-7.57.0/lib' make all-am make[2]: Entering directory `/root/curl-7.57.0/lib' make[2]: Leaving directory `/root/curl-7.57.0/lib' make[1]: Leaving directory `/root/curl-7.57.0/lib' Making all in src make[1]: Entering directory `/root/curl-7.57.0/src' Making all in ../docs make[2]: Entering directory `/root/curl-7.57.0/docs' Making all in . make[3]: Entering directory `/root/curl-7.57.0/docs' make[3]: Nothing to be done for `all-am'. make[3]: Leaving directory `/root/curl-7.57.0/docs' Making all in cmdline-opts make[3]: Entering directory `/root/curl-7.57.0/docs/cmdline-opts' make[3]: Nothing to be done for `all'. make[3]: Leaving directory `/root/curl-7.57.0/docs/cmdline-opts' make[2]: Leaving directory `/root/curl-7.57.0/docs' make[2]: Entering directory `/root/curl-7.57.0/src' CCLD curl ../lib/.libs/libcurl.so: undefined reference to `SSLv23_client_method' ../lib/.libs/libcurl.so: undefined reference to `CONF_modules_free' ../lib/.libs/libcurl.so: undefined reference to `ERR_free_strings' ../lib/.libs/libcurl.so: undefined reference to `sk_value' ../lib/.libs/libcurl.so: undefined reference to `SSL_library_init' ../lib/.libs/libcurl.so: undefined reference to `sk_pop_free' ../lib/.libs/libcurl.so: undefined reference to `SSLeay' ../lib/.libs/libcurl.so: undefined reference to `SSLv3_client_method' ../lib/.libs/libcurl.so: undefined reference to `OPENSSL_add_all_algorithms_noconf' ../lib/.libs/libcurl.so: undefined reference to `SSL_COMP_free_compression_methods' ../lib/.libs/libcurl.so: undefined reference to `EVP_cleanup' ../lib/.libs/libcurl.so: undefined reference to `sk_num' ../lib/.libs/libcurl.so: undefined reference to `sk_pop' ../lib/.libs/libcurl.so: undefined reference to `SSL_load_error_strings' collect2: error: ld returned 1 exit status make[2]: *** [curl] Error 1 make[2]: Leaving directory `/root/curl-7.57.0/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/root/curl-7.57.0/src' make: *** [all-recursive] Error 1 ``` ![error](https://img-ask.csdn.net/upload/201801/18/1516246775_986852.png)

LIBCURL.DLL FTP 客户端

``` int CEVDownLoadDlg::FtpUploadFile(CURL * curl,char *pUrl, unsigned short usPort,FILE * fpUploadFile, int nUploadFileSize) { ASSERT(curl != NULL); curl_easy_reset(curl); curl_easy_setopt(curl, CURLOPT_HEADER, 0); char szCurlUrl[128] = { 0 }; sprintf(szCurlUrl, "%s", pUrl); curl_easy_setopt(curl, CURLOPT_URL, szCurlUrl); curl_easy_setopt(curl, CURLOPT_PORT, 21); /*user & pwd*/ std::string NameAndKey = "root:000111"; curl_easy_setopt(curl, CURLOPT_USERPWD, NameAndKey.c_str()); FILE *ptempfile = fopen("E:\\DTools_Debug\\Projects\\1001.txt", "rb"); long nsize; if (ptempfile!=NULL) { fseek(ptempfile,0,SEEK_END); nsize = ftell(ptempfile); fseek(ptempfile,0,SEEK_SET); } curl_easy_setopt(curl, CURLOPT_READDATA, ptempfile); curl_easy_setopt(curl, CURLOPT_READFUNCTION,FtpReadFunction); curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); curl_easy_setopt(curl, CURLOPT_INFILESIZE, nsize); // curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, 1); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 5); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5); CURLcode res = curl_easy_perform(curl); /* Check for errors */ if (res != CURLE_OK) { return 1; } return 0; } size_t CEVDownLoadDlg::FtpReadFunction(void *ptr, size_t size, size_t nmemb, void *stream) { if (stream == NULL || ptr == NULL || size == 0) return 0; FILE* pfile = (FILE*)stream; size_t retcode=fread(ptr,size,nmemb,pfile);//read return retcode; } ``` 求大佬分析一下 问题1:FtpReadFunction中 nmenber 大小怎么设置 curl_easy_setopt(curl, CURLOPT_INFILESIZE, nsize);好像没有影响 问题2:CURLcode res = curl_easy_perform(curl); 报错(LIBCURL.DLL): 0xC0000005: Access Violation. (汇编 mov dword ptr [eax],esi) 其中eax=0;

如何为https网站选择CURL代理?

<div class="post-text" itemprop="text"> <p>I'm trying to connect to a website using <code>CURL</code> on <code>localhost</code>, I tried many proxies but most of them didn't work.</p> <p>Here is the code:</p> <pre><code>$url= 'https://stubhub.com'; $curl = curl_init(); curl_setopt( $curl, CURLOPT_URL, $url ); curl_setopt($curl, CURLOPT_REFERER, $url); curl_setopt( $curl, CURLOPT_AUTOREFERER, TRUE ); curl_setopt( $curl, CURLOPT_HEADER, FALSE ); curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 0 ); curl_setopt( $curl, CURLOPT_TIMEOUT, 0 ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE ); curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, TRUE ); curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); //certificate $cacert='C:/xampp/cacert.pem'; curl_setopt( $curl, CURLOPT_CAINFO, $cacert ); //SSL curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); //Cookies curl_setopt($curl, CURLOPT_COOKIEFILE,__DIR__."/cookie.txt"); //User-Agent curl_setopt( $curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' ); //Proxy $proxy = '50.115.194.97:8080'; curl_setopt($curl, CURLOPT_PROXY, $proxy); curl_setopt($curl, CURLOPT_PROXYPORT, 443); curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, TRUE); //Errors curl_setopt($curl, CURLOPT_VERBOSE, TRUE); $data = curl_exec( $curl ); $info = curl_getinfo( $curl ); $error = curl_error( $curl ); curl_close( $curl ); $allInfo = array($data, Info, $error); echo '&lt;pre&gt;'; print_r($allInfo); echo '&lt;/pre&gt;'; </code></pre> <p>I get the following response:</p> <pre><code>Array ( [0] =&gt; [1] =&gt; Array ( [url] =&gt; https://stubhub.com/ [content_type] =&gt; [http_code] =&gt; 0 [header_size] =&gt; 0 [request_size] =&gt; 0 [filetime] =&gt; -1 [ssl_verify_result] =&gt; 0 [redirect_count] =&gt; 0 [total_time] =&gt; 20.203 [namelookup_time] =&gt; 0 [connect_time] =&gt; 0 [pretransfer_time] =&gt; 0 [size_upload] =&gt; 0 [size_download] =&gt; 0 [speed_download] =&gt; 0 [speed_upload] =&gt; 0 [download_content_length] =&gt; -1 [upload_content_length] =&gt; -1 [starttransfer_time] =&gt; 0 [redirect_time] =&gt; 0 [redirect_url] =&gt; [primary_ip] =&gt; [certinfo] =&gt; Array ( ) [primary_port] =&gt; 0 [local_ip] =&gt; [local_port] =&gt; 0 ) [2] =&gt; Failed to connect to 50.115.194.97 port 8080: Timed out ) </code></pre> <p>I tried with proxies that supports <code>https</code>, cookies and those with <code>443</code> port.</p> <p>Is there is an API/library for this purpose?</p> </div>

linu下用libcurl库下载文件报错问题

最近在做linux下用libcurl从自己搭建的http服务器上下载文件,代码写好,编译ok,但是每次给出url时,总是报错url格式错误,哪位大神能帮忙看看呢

Protocol https not supported or disabled in libcurl

1.PHP使用curl发送post请求提示标题错误. 2.代码演示 ```php function curlPost($url, $data = array()) { if (is_array($data)) { $data = http_build_query($data); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_TIMEOUT, 30); if (!empty($options)) { curl_setopt_array($ch, $options); } $data = curl_exec($ch); recordLog(1,curl_error($ch)); curl_close($ch); return $data; } ``` 3.问题解决 需要加上如下代码 ```php // 访问的借口为https协议时 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); ``` 4.其它原因 a.有可能url中有空格

c++使用libcurl 多线程的问题

多个请求 easy handle 添加到 multi handle里面,然后执行curl_multi_performance,但是执行到一半的时候发生网络故障,但是函数还是执行成功,且running_handle参数一直不变,请教如何判断哪些请求失败了。 代码片段如下: ... CURLMcode curMCode; CURLM * curl_m = curl_multi_init(); const int reqNum = 1000; CURL* curlArr[reqNum]; for (auto& cur : curlArr) { cur = GetKLineReqCUrl(); curMCode = curl_multi_add_handle(curl_m, cur); } int running_handles = 0; while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(curl_m, &running_handles)) { cout << running_handles << endl; } do { int numfds = 0; CURLMcode _waitResult = curl_multi_wait(curl_m, NULL, 0, 20000, &numfds); // 此函数永远返回成功,发生错误的时候numfds为0 if (_waitResult != CURLM_OK) { std::cout << "curl_multi_wait return: " << _waitResult << std::endl; } curMCode = curl_multi_perform(curl_m, &running_handles); // 发生故障的时候返回值也一直是CURLM_OK,且running_handles一直不减少 } while (running_handles); std::cout << "curl_multi_perform completed" << std::endl; int msgs_left; CURLMsg * msg; while (msg = curl_multi_info_read(curl_m, &msgs_left)) { if (CURLMSG_DONE == msg->msg) { cout << "recv result: " << msg->data.result << endl; } } for (auto cur : curlArr) { curl_multi_remove_handle(curl_m, cur); curl_easy_cleanup(cur); } curl_multi_cleanup(curl_m); ...

使用cURL进行的SSL请求在进程分叉后失败

<div class="post-text" itemprop="text"> <p>I have run into some pretty strange behaviour with curl</p> <ol> <li>If I make an SSL request using curl in the parent process and then fork the process and try to make another SSL request in the child process the attempt fails with error no. 35 (SSL connect error).</li> <li>If I do not make the SSL request in the parent, the one in the child process succeeds. </li> <li>I can make any number of non SSL requests in the parent and SSL requests in the child succeed.</li> </ol> <p>It appears that this is a bug in libcurl <a href="https://stackoverflow.com/questions/15466809/libcurl-ssl-error-after-fork">related question</a> and the answerer has a <a href="http://www.manpagez.com/man/3/curl_global_cleanup/osx-10.3.php" rel="nofollow noreferrer">work around for it</a>. </p> <p>My questions are:</p> <ol> <li>Is <a href="http://www.manpagez.com/man/3/curl_global_cleanup/osx-10.3.php" rel="nofollow noreferrer">curl_global_cleanup</a> exposed by some other name in the PHP API?</li> <li>If not is there some other work around?</li> </ol> <p> </p><pre><code>$ch = curl_init('https://www.google.ca/'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $success = curl_exec($ch); var_dump($success !== false); // true curl_close($ch); $pid = pcntl_fork(); if ($pid === 0) { $ch = curl_init('http://www.google.ca/'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $success = curl_exec($ch); var_dump($success !== false); // true curl_close($ch); $ch = curl_init('https://www.google.ca/'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $success = curl_exec($ch); var_dump($success !== false); // false $errno = curl_errno($ch); // 35 $error = curl_error($ch); // SSL connect error curl_close($ch); } else if ($pid &gt; 0) { // wait for child process pcntl_wait($status); } else { // handel fork error } </code></pre> <p>If this is not a bug with libcurl and it is something I am doing wrong please let me know.</p> </div>

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

删库了,我们一定要跑路吗?

在工作中,我们误删数据或者数据库,我们一定需要跑路吗?我看未必,程序员一定要学会自救,神不知鬼不觉的将数据找回。 在 mysql 数据库中,我们知道 binlog 日志记录了我们对数据库的所有操作,所以 binlog 日志就是我们自救的利器。 接下来就来开启程序员自救之路。 想要自救成功,binlog 这把利器一定要好,在自己之前,我们一定要确定我们有 binlog 这把利器,以下就是确保有 bi...

再不跳槽,应届毕业生拿的都比我多了!

跳槽几乎是每个人职业生涯的一部分,很多HR说“三年两跳”已经是一个跳槽频繁与否的阈值了,可为什么市面上有很多程序员不到一年就跳槽呢?他们不担心影响履历吗? PayScale之前发布的**《员工最短任期公司排行榜》中,两家码农大厂Amazon和Google**,以1年和1.1年的员工任期中位数分列第二、第四名。 PayScale:员工最短任期公司排行榜 意外的是,任期中位数极小的这两家公司,薪资...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

华为初面+综合面试(Java技术面)附上面试题

华为面试整体流程大致分为笔试,性格测试,面试,综合面试,回学校等结果。笔试来说,华为的难度较中等,选择题难度和网易腾讯差不多。最后的代码题,相比下来就简单很多,一共3道题目,前2题很容易就AC,题目已经记不太清楚,不过难度确实不大。最后一题最后提交的代码过了75%的样例,一直没有发现剩下的25%可能存在什么坑。 笔试部分太久远,我就不怎么回忆了。直接将面试。 面试 如果说腾讯的面试是挥金如土...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

外包程序员的幸福生活

今天给你们讲述一个外包程序员的幸福生活。男主是Z哥,不是在外包公司上班的那种,是一名自由职业者,接外包项目自己干。接下来讲的都是真人真事。 先给大家介绍一下男主,Z哥,老程序员,是我十多年前的老同事,技术大牛,当过CTO,也创过业。因为我俩都爱好喝酒、踢球,再加上住的距离不算远,所以一直也断断续续的联系着,我对Z哥的状况也有大概了解。 Z哥几年前创业失败,后来他开始干起了外包,利用自己的技术能...

现代的 “Hello, World”,可不仅仅是几行代码而已

作者 |Charles R. Martin译者 | 弯月,责编 | 夕颜头图 |付费下载自视觉中国出品 | CSDN(ID:CSDNnews)新手...

!大部分程序员只会写3年代码

如果世界上都是这种不思进取的软件公司,那别说大部分程序员只会写 3 年代码,恐怕就没有程序员这种职业。

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

HTTP与HTTPS的区别

面试官问HTTP与HTTPS的区别,我这样回答让他竖起大拇指!

程序员毕业去大公司好还是小公司好?

虽然大公司并不是人人都能进,但我仍建议还未毕业的同学,尽力地通过校招向大公司挤,但凡挤进去,你这一生会容易很多。 大公司哪里好?没能进大公司怎么办?答案都在这里了,记得帮我点赞哦。 目录: 技术氛围 内部晋升与跳槽 啥也没学会,公司倒闭了? 不同的人脉圈,注定会有不同的结果 没能去大厂怎么办? 一、技术氛围 纵观整个程序员技术领域,哪个在行业有所名气的大牛,不是在大厂? 而且众所...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

立即提问
相关内容推荐