VirtualBox

source: vbox/trunk/src/libs/curl-7.87.0/lib/connect.h@ 98334

Last change on this file since 98334 was 98326, checked in by vboxsync, 2 years ago

curl-7.87.0: Applied and adjusted our curl changes to 7.83.1. bugref:10356

  • Property svn:eol-style set to native
File size: 5.8 KB
Line 
1#ifndef HEADER_CURL_CONNECT_H
2#define HEADER_CURL_CONNECT_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) 1998 - 2022, Daniel Stenberg, <[email protected]>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26#include "curl_setup.h"
27
28#include "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */
29#include "sockaddr.h"
30#include "timeval.h"
31
32CURLcode Curl_connecthost(struct Curl_easy *data,
33 struct connectdata *conn,
34 const struct Curl_dns_entry *host);
35
36/* generic function that returns how much time there's left to run, according
37 to the timeouts set */
38timediff_t Curl_timeleft(struct Curl_easy *data,
39 struct curltime *nowp,
40 bool duringconnect);
41
42#define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */
43
44/*
45 * Used to extract socket and connectdata struct for the most recent
46 * transfer on the given Curl_easy.
47 *
48 * The returned socket will be CURL_SOCKET_BAD in case of failure!
49 */
50curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
51 struct connectdata **connp);
52
53bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
54 char *addr, int *port);
55
56/*
57 * Check if a connection seems to be alive.
58 */
59bool Curl_connalive(struct Curl_easy *data, struct connectdata *conn);
60
61#ifdef USE_WINSOCK
62/* When you run a program that uses the Windows Sockets API, you may
63 experience slow performance when you copy data to a TCP server.
64
65 https://support.microsoft.com/kb/823764
66
67 Work-around: Make the Socket Send Buffer Size Larger Than the Program Send
68 Buffer Size
69
70*/
71void Curl_sndbufset(curl_socket_t sockfd);
72#else
73#define Curl_sndbufset(y) Curl_nop_stmt
74#endif
75
76void Curl_updateconninfo(struct Curl_easy *data, struct connectdata *conn,
77 curl_socket_t sockfd);
78void Curl_conninfo_remote(struct Curl_easy *data, struct connectdata *conn,
79 curl_socket_t sockfd);
80void Curl_conninfo_local(struct Curl_easy *data, curl_socket_t sockfd,
81 char *local_ip, int *local_port);
82void Curl_persistconninfo(struct Curl_easy *data, struct connectdata *conn,
83 char *local_ip, int local_port);
84int Curl_closesocket(struct Curl_easy *data, struct connectdata *conn,
85 curl_socket_t sock);
86
87/*
88 * The Curl_sockaddr_ex structure is basically libcurl's external API
89 * curl_sockaddr structure with enough space available to directly hold any
90 * protocol-specific address structures. The variable declared here will be
91 * used to pass / receive data to/from the fopensocket callback if this has
92 * been set, before that, it is initialized from parameters.
93 */
94struct Curl_sockaddr_ex {
95 int family;
96 int socktype;
97 int protocol;
98 unsigned int addrlen;
99 union {
100 struct sockaddr addr;
101 struct Curl_sockaddr_storage buff;
102 } _sa_ex_u;
103};
104#define sa_addr _sa_ex_u.addr
105
106/*
107 * Create a socket based on info from 'conn' and 'ai'.
108 *
109 * Fill in 'addr' and 'sockfd' accordingly if OK is returned. If the open
110 * socket callback is set, used that!
111 *
112 */
113CURLcode Curl_socket(struct Curl_easy *data,
114 const struct Curl_addrinfo *ai,
115 struct Curl_sockaddr_ex *addr,
116 curl_socket_t *sockfd);
117
118/*
119 * Curl_conncontrol() marks the end of a connection/stream. The 'closeit'
120 * argument specifies if it is the end of a connection or a stream.
121 *
122 * For stream-based protocols (such as HTTP/2), a stream close will not cause
123 * a connection close. Other protocols will close the connection for both
124 * cases.
125 *
126 * It sets the bit.close bit to TRUE (with an explanation for debug builds),
127 * when the connection will close.
128 */
129
130#define CONNCTRL_KEEP 0 /* undo a marked closure */
131#define CONNCTRL_CONNECTION 1
132#define CONNCTRL_STREAM 2
133
134void Curl_conncontrol(struct connectdata *conn,
135 int closeit
136#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
137 , const char *reason
138#endif
139 );
140
141#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
142#define streamclose(x,y) Curl_conncontrol(x, CONNCTRL_STREAM, y)
143#define connclose(x,y) Curl_conncontrol(x, CONNCTRL_CONNECTION, y)
144#define connkeep(x,y) Curl_conncontrol(x, CONNCTRL_KEEP, y)
145#else /* if !DEBUGBUILD || CURL_DISABLE_VERBOSE_STRINGS */
146#define streamclose(x,y) Curl_conncontrol(x, CONNCTRL_STREAM)
147#define connclose(x,y) Curl_conncontrol(x, CONNCTRL_CONNECTION)
148#define connkeep(x,y) Curl_conncontrol(x, CONNCTRL_KEEP)
149#endif
150
151CURLcode Curl_conn_socket_set(struct Curl_easy *data,
152 struct connectdata *conn,
153 int sockindex);
154
155CURLcode Curl_conn_socket_accepted_set(struct Curl_easy *data,
156 struct connectdata *conn,
157 int sockindex,
158 curl_socket_t *s);
159
160#endif /* HEADER_CURL_CONNECT_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette