• man curl_global_init(原创)


    curl_global_init(3)             libcurl 手册             curl_global_init(3)

    名称

    curl_global_init - libcurl库全局的初始化

    概要

    #include <curl/curl.h>

         CURLcode curl_global_init(long flags);

    描述

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

    这个按位组合选择的整形(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,悲剧就发生了。这种情况发生的概率很小,但可能性是存在的。

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

    标志

    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)
  • 相关阅读:
    django的信号
    网络安全
    网络干货,无论是运维还是开发都要知道的网络知识系列之(九)
    一些职场的忠告
    自动化测试如何解决验证码的问题
    通过python切换hosts文件
    【转】web常见安全问题以及测试方法
    【转】做好软件测试需要具备的思维方式
    【转】创业泡沫的「军功章」,高薪低能的程序员要分走一半
    【转】黑盒测试中的一些小经验分享
  • 原文地址:https://www.cnblogs.com/jikexianfeng/p/6092161.html
Copyright © 2020-2023  润新知