curl之网络接口

Curl_cftype

连接接口定义

struct Curl_cftype {
   
  const char *name;                       /* name of the filter type */
  int flags;                              /* flags of filter type */
  int log_level;                          /* log level for such filters */
  Curl_cft_destroy_this *destroy;         /* destroy resources of this cf */
  Curl_cft_connect *do_connect;           /* establish connection */
  Curl_cft_close *do_close;               /* close conn */
  Curl_cft_get_host *get_host;            /* host filter talks to */
  Curl_cft_adjust_pollset *adjust_pollset; /* adjust transfer poll set */
  Curl_cft_data_pending *has_data_pending;/* conn has data pending */
  Curl_cft_send *do_send;                 /* send data */
  Curl_cft_recv *do_recv;                 /* receive data */
  Curl_cft_cntrl *cntrl;                  /* events/control */
  Curl_cft_conn_is_alive *is_alive;       /* FALSE if conn is dead, Jim! */
  Curl_cft_conn_keep_alive *keep_alive;   /* try to keep it alive */
  Curl_cft_query *query;                  /* query filter chain */
};

初始化Curl_cftype类型数组

数组定义为struct Curl_cftype *cf_types

static struct Curl_cftype *cf_types[] = {
   
  &Curl_cft_tcp,
  &Curl_cft_udp,
  &Curl_cft_unix,
  &Curl_cft_tcp_accept,
  &Curl_cft_happy_eyeballs,
  &Curl_cft_setup,
#ifdef USE_NGHTTP2
  &Curl_cft_nghttp2,
#endif
#ifdef USE_SSL
  &Curl_cft_ssl,
#ifndef CURL_DISABLE_PROXY
  &Curl_cft_ssl_proxy,
#endif
#endif
#if !defined(CURL_DISABLE_PROXY)
#if !defined(CURL_DISABLE_HTTP)
  &Curl_cft_h1_proxy,
#ifdef USE_NGHTTP2
  &Curl_cft_h2_proxy,
#endif
  &Curl_cft_http_proxy,
#endif /* !CURL_DISABLE_HTTP */
  &Curl_cft_haproxy,
  &Curl_cft_socks_proxy,
#endif /* !CURL_DISABLE_PROXY */
#ifdef ENABLE_QUIC
  &Curl_cft_http3,
#endif
#if !defined(CURL_DISABLE_HTTP) && !defined(USE_HYPER)
  &Curl_cft_http_connect,
#endif
  NULL,
};

Curl_cfilter

连接处理链

struct Curl_cfilter {
   
  const struct Curl_cftype *cft; /* the type providing implementation */
  struct Curl_cfilter *next;     /* next filter in chain */
  void *ctx;                     /* filter type specific settings */
  struct connectdata *conn;      /* the connection this filter belongs to */
  int sockindex;                 /* the index the filter is installed at */
  BIT(connected);                /* != 0 iff this filter is connected */
};

transport_provider

定义如下

struct transport_provider {
   
  int transport;
  cf_ip_connect_create *cf_create;
};

初始化代码为

struct transport_provider transport_providers[] = {
   
  {
    TRNSPRT_TCP, Curl_cf_tcp_create },
#ifdef ENABLE_QUIC
  {
    TRNSPRT_QUIC, Curl_cf_quic_create },
#endif
#ifndef CURL_DISABLE_TFTP
  {
    TRNSPRT_UDP, Curl_cf_udp_create },
#endif
#ifdef USE_UNIX_SOCKETS
  {
    TRNSPRT_UNIX, Curl_cf_unix_create },
#endif
};

相关推荐

  1. curl网络接口

    2024-02-03 09:08:02       35 阅读
  2. Linux 使用 curl 调用接口

    2024-02-03 09:08:02       33 阅读
  3. Linux 网络请求工具:curl

    2024-02-03 09:08:02       4 阅读
  4. PHPcurl详细讲解

    2024-02-03 09:08:02       41 阅读
  5. PHPCURL和Socket

    2024-02-03 09:08:02       19 阅读
  6. 每天学习一个Linux命令curl

    2024-02-03 09:08:02       24 阅读
  7. php接口优化 使用curl_multi_init批量请求

    2024-02-03 09:08:02       37 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-02-03 09:08:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-03 09:08:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-03 09:08:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-03 09:08:02       20 阅读

热门阅读

  1. Spring MVC 框架无法找到合适的消息转换器

    2024-02-03 09:08:02       27 阅读
  2. CSS 选择器与相关规则详解

    2024-02-03 09:08:02       34 阅读
  3. JeecgBoot 3.6.1 vue页面定时刷新列表

    2024-02-03 09:08:02       35 阅读
  4. golang 中间件使用

    2024-02-03 09:08:02       35 阅读
  5. 算法篇:递归、搜索与回溯算法

    2024-02-03 09:08:02       28 阅读
  6. Android CameraManager 使用

    2024-02-03 09:08:02       30 阅读