man curl_global_init(原创)

curl_global_init(3)             libcurl 手册             curl_global_init(3)编程

 

名称安全

curl_global_init - libcurl库全局的初始化多线程

 

概要less

#include <curl/curl.h>curl

     CURLcode curl_global_init(long flags);socket

 

描述函数

在调应libcurl库中其余函数以前,必须先调用这个函数对编程环境进行相应的初始化,使每一个程序调用libcurl库函数都具备相同的效果。ui

这个按位组合选择的整形(int)变量能够精确告诉libcurl当下的须要的工做模式。详细状况,若是你不是十分熟悉总体参数的初始化,您能够设置参数为CURL_GLOABL_ALL。对全部的须要用到的环境进行初始化,这个函数不是安全线程,在多线程应用中,须要在主线程中调用这个函数。这个函数设置libcurl所需的环境。一般状况,若是不显式的调用它,第一次调用 curl_easy_init()时,curl_easy_init 会调用 curl_global_init,在单线程环境下,这不是问题。可是多线程下就不行了,由于curl_global_init不是线程安全的。在多个线 程中调用curl_easy_int,而后若是两个线程同时发现curl_global_init尚未被调用,同时调用 curl_global_init,悲剧就发生了。这种状况发生的几率很小,但可能性是存在的。this

         看到libcurl的描述(3)的全局环境要求的细节如何使用这个函数。url

标志

CURL_GLOBAL_ALL

初始化全部已知设置,除了后台传输服务。CURL_GLOBAL_ACK_EINTR.

CURL_GLOBAL_SSL

            初始化 SSL(安全套接层)

CURL_GLOBAL_WIN32

            初始化Win32 因此共享函数包.

 

CURL_GLOBAL_NOTHING

什么都不初始化This sets no bit.

CURL_GLOBAL_DEFAULT

一个合理的默认值。它将init SSL和Win32。如今,这个等于CURL_GLOBAL_ALL面具的功能。

CURL_GLOBAL_ACK_EINTR

这个标志被设置时,旋度认可当链接或在等待数据捕获条件。不然,旋度等待超时白白的流逝了。在7.30.0(添加)

返回值

若是这个函数返回非零,出了意外,你不能使用其余旋度函数。

另请参阅

curl_global_init_mem(3),    curl_global_cleanup(3),   curl_easy_init(3),  libcurl(3)

 

libcurl 7.12                    11 May 2004                         curl_global_init(3)

 

 

curl_global_init(3)             libcurl Manual             curl_global_init(3)

NAME
       curl_global_init - Global libcurl initialisation

SYNOPSIS
       #include <curl/curl.h>

       CURLcode curl_global_init(long flags);

DESCRIPTION
       This  function  sets  up  the  program  environment that libcurl needs.
       Think of it as an extension of the library loader.

       This function must be called at least once within a program (a  program
       is  all  the  code that shares a memory space) before the program calls
       any other function in libcurl.  The environment it sets up is  constant
       for  the life of the program and is the same for every program, so mul‐
       tiple calls have the same effect as one call.

       The flags option is a bit pattern that tells libcurl exactly what  fea‐
       tures  to  init,  as described below. Set the desired bits by ORing the
       values   together.    In   normal   operation,   you    must    specify
       CURL_GLOBAL_ALL.   Don't  use  any  other value unless you are familiar
       with it and mean to control internal operations of libcurl.

       This function is not thread safe. You must not call it when  any  other
       thread  in  the program (i.e. a thread sharing the same memory) is run‐
       ning.  This doesn't just mean no other thread that  is  using  libcurl.
       Because curl_global_init(3) calls functions of other libraries that are
       similarly thread unsafe, it could conflict with any other  thread  that
       uses these other libraries.

       If  you are initializing libcurl from a Windows DLL you should not ini‐
       tialize it from DllMain or a static initializer because  Windows  holds
       the loader lock during that time and it could cause a deadlock.

       See  the  description  in libcurl(3) of global environment requirements
       for details of how to use this function.

FLAGS
       CURL_GLOBAL_ALL
            Initialize everything possible. This sets all  known  bits  except
            CURL_GLOBAL_ACK_EINTR.

       CURL_GLOBAL_SSL
            Initialize SSL

       CURL_GLOBAL_WIN32
            Initialize the Win32 socket libraries.

       CURL_GLOBAL_NOTHING
            Initialise nothing extra. This sets no bit.

       CURL_GLOBAL_DEFAULT
            A  sensible  default.  It will init both SSL and Win32. Right now,
            this equals the functionality of the CURL_GLOBAL_ALL mask.

       CURL_GLOBAL_ACK_EINTR
            When this flag is set, curl will acknowledge EINTR condition  when
            connecting  or when waiting for data.  Otherwise, curl waits until
            full timeout elapses. (Added in 7.30.0)

RETURN VALUE
       If this function returns non-zero, something went wrong and you  cannot
       use the other curl functions.

SEE ALSO
       curl_global_init_mem(3),    curl_global_cleanup(3),   curl_easy_init(3)
       libcurl(3)

libcurl 7.12                      11 May 2004              curl_global_init(3)
相关文章
相关标签/搜索
本站公众号
   欢迎关注本站公众号,获取更多信息