connect.h
Go to the documentation of this file.
00001 #ifndef HEADER_CURL_CONNECT_H
00002 #define HEADER_CURL_CONNECT_H
00003 /***************************************************************************
00004  *                                  _   _ ____  _
00005  *  Project                     ___| | | |  _ \| |
00006  *                             / __| | | | |_) | |
00007  *                            | (__| |_| |  _ <| |___
00008  *                             \___|\___/|_| \_\_____|
00009  *
00010  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
00011  *
00012  * This software is licensed as described in the file COPYING, which
00013  * you should have received as part of this distribution. The terms
00014  * are also available at https://curl.haxx.se/docs/copyright.html.
00015  *
00016  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00017  * copies of the Software, and permit persons to whom the Software is
00018  * furnished to do so, under the terms of the COPYING file.
00019  *
00020  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00021  * KIND, either express or implied.
00022  *
00023  ***************************************************************************/
00024 #include "curl_setup.h"
00025 
00026 #include "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */
00027 #include "sockaddr.h"
00028 
00029 CURLcode Curl_is_connected(struct connectdata *conn,
00030                            int sockindex,
00031                            bool *connected);
00032 
00033 CURLcode Curl_connecthost(struct connectdata *conn,
00034                           const struct Curl_dns_entry *host);
00035 
00036 /* generic function that returns how much time there's left to run, according
00037    to the timeouts set */
00038 time_t Curl_timeleft(struct Curl_easy *data,
00039                      struct timeval *nowp,
00040                      bool duringconnect);
00041 
00042 #define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */
00043 #define HAPPY_EYEBALLS_TIMEOUT     200 /* milliseconds to wait between
00044                                           IPv4/IPv6 connection attempts */
00045 
00046 /*
00047  * Used to extract socket and connectdata struct for the most recent
00048  * transfer on the given Curl_easy.
00049  *
00050  * The returned socket will be CURL_SOCKET_BAD in case of failure!
00051  */
00052 curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
00053                                   struct connectdata **connp);
00054 
00055 /*
00056  * Check if a connection seems to be alive.
00057  */
00058 bool Curl_connalive(struct connectdata *conn);
00059 
00060 #ifdef USE_WINSOCK
00061 /* When you run a program that uses the Windows Sockets API, you may
00062    experience slow performance when you copy data to a TCP server.
00063 
00064    https://support.microsoft.com/kb/823764
00065 
00066    Work-around: Make the Socket Send Buffer Size Larger Than the Program Send
00067    Buffer Size
00068 
00069 */
00070 void Curl_sndbufset(curl_socket_t sockfd);
00071 #else
00072 #define Curl_sndbufset(y) Curl_nop_stmt
00073 #endif
00074 
00075 void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd);
00076 void Curl_persistconninfo(struct connectdata *conn);
00077 int Curl_closesocket(struct connectdata *conn, curl_socket_t sock);
00078 
00079 /*
00080  * The Curl_sockaddr_ex structure is basically libcurl's external API
00081  * curl_sockaddr structure with enough space available to directly hold any
00082  * protocol-specific address structures. The variable declared here will be
00083  * used to pass / receive data to/from the fopensocket callback if this has
00084  * been set, before that, it is initialized from parameters.
00085  */
00086 struct Curl_sockaddr_ex {
00087   int family;
00088   int socktype;
00089   int protocol;
00090   unsigned int addrlen;
00091   union {
00092     struct sockaddr addr;
00093     struct Curl_sockaddr_storage buff;
00094   } _sa_ex_u;
00095 };
00096 #define sa_addr _sa_ex_u.addr
00097 
00098 /*
00099  * Create a socket based on info from 'conn' and 'ai'.
00100  *
00101  * Fill in 'addr' and 'sockfd' accordingly if OK is returned. If the open
00102  * socket callback is set, used that!
00103  *
00104  */
00105 CURLcode Curl_socket(struct connectdata *conn,
00106                      const Curl_addrinfo *ai,
00107                      struct Curl_sockaddr_ex *addr,
00108                      curl_socket_t *sockfd);
00109 
00110 void Curl_tcpnodelay(struct connectdata *conn, curl_socket_t sockfd);
00111 
00112 /*
00113  * Curl_conncontrol() marks the end of a connection/stream. The 'closeit'
00114  * argument specifies if it is the end of a connection or a stream.
00115  *
00116  * For stream-based protocols (such as HTTP/2), a stream close will not cause
00117  * a connection close. Other protocols will close the connection for both
00118  * cases.
00119  *
00120  * It sets the bit.close bit to TRUE (with an explanation for debug builds),
00121  * when the connection will close.
00122  */
00123 
00124 #define CONNCTRL_KEEP 0 /* undo a marked closure */
00125 #define CONNCTRL_CONNECTION 1
00126 #define CONNCTRL_STREAM 2
00127 
00128 void Curl_conncontrol(struct connectdata *conn,
00129                       int closeit
00130 #ifdef DEBUGBUILD
00131                       , const char *reason
00132 #endif
00133   );
00134 
00135 #ifdef DEBUGBUILD
00136 #define streamclose(x,y) Curl_conncontrol(x, CONNCTRL_STREAM, y)
00137 #define connclose(x,y) Curl_conncontrol(x, CONNCTRL_CONNECTION, y)
00138 #define connkeep(x,y) Curl_conncontrol(x, CONNCTRL_KEEP, y)
00139 #else /* if !CURLDEBUG */
00140 #define streamclose(x,y) Curl_conncontrol(x, CONNCTRL_STREAM)
00141 #define connclose(x,y) Curl_conncontrol(x, CONNCTRL_CONNECTION)
00142 #define connkeep(x,y) Curl_conncontrol(x, CONNCTRL_KEEP)
00143 #endif
00144 
00145 bool Curl_conn_data_pending(struct connectdata *conn, int sockindex);
00146 
00147 #endif /* HEADER_CURL_CONNECT_H */


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:02