1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
;
;
;
;
/**
* Generic event function for channel lifecycle events.
*
* Callbacks are provided for:
* (1) Channel creation
* (2) Channel setup - If TLS is being used, this function is called once the socket has connected, the channel has
* been initialized, and TLS has been successfully negotiated. A TLS handler has already been added to the channel. If
* TLS negotiation fails, this function will be called with the corresponding error code. If TLS is not being used, this
* function is called once the socket has connected and the channel has been initialized.
* (3) Channel shutdown
*
* These callbacks are always invoked within the thread of the event-loop that the channel is assigned to.
*
* This function does NOT always imply "success" -- if error_code is AWS_OP_SUCCESS then everything was successful,
* otherwise an error condition occurred.
*/
typedef void;
/**
* If ALPN is being used this function will be invoked by the channel once an ALPN message is received. The returned
* channel_handler will be added to, and managed by, the channel.
*/
typedef struct aws_channel_handler *;
;
;
/**
* Called after client bootstrap has been completely cleaned up, after its last refcount is released.
*/
typedef void ;
/**
* aws_client_bootstrap handles creation and setup of channels that communicate via socket with a specific endpoint.
*/
;
/**
* aws_client_bootstrap creation options.
*/
;
;
/**
* If TLS is being used, this function is called once the socket has received an incoming connection, the channel has
* been initialized, and TLS has been successfully negotiated. A TLS handler has already been added to the channel. If
* TLS negotiation fails, this function will be called with the corresponding error code.
*
* If TLS is not being used, this function is called once the socket has received an incoming connection and the channel
* has been initialized.
*
* This function is always called within the thread of the event-loop that the new channel is assigned to upon success.
*
* On failure, the channel might not be assigned to an event loop yet, and will thus be invoked on the listener's
* event-loop thread.
*
* This function does NOT mean "success", if error_code is AWS_OP_SUCCESS then everything was successful, otherwise an
* error condition occurred.
*
* If an error occurred, you do not need to shutdown the channel. The `aws_channel_client_shutdown_callback` will be
* invoked once the channel has finished shutting down.
*/
typedef void;
/**
* Once the channel shuts down, this function will be invoked within the thread of
* the event-loop that the channel is assigned to.
*
* Note: this function is only invoked if the channel was successfully setup,
* e.g. aws_server_bootstrap_on_accept_channel_setup_fn() was invoked without an error code.
*/
typedef void;
/**
* Once the server listener socket is finished destroying, and all the existing connections are closed, this fuction
* will be invoked.
*/
typedef void;
/**
* aws_server_bootstrap manages listening sockets, creating and setting up channels to handle each incoming connection.
*/
;
/**
* Socket-based channel creation options.
*
* bootstrap - configs name resolution and which event loop group the connection will be seated into
* host_name - host to connect to; if a dns address, will be resolved prior to connecting
* port - port to connect to
* socket_options - socket properties, including type (tcp vs. udp vs. unix domain) and connect timeout. TLS
* connections are currently restricted to tcp (AWS_SOCKET_STREAM) only.
* tls_options - (optional) tls context to apply after connection establishment. If NULL, the connection will
* not be protected by TLS.
* creation_callback - (optional) callback invoked when the channel is first created. This is always right after
* the connection was successfully established. *Does NOT* get called if the initial connect failed.
* setup_callback - callback invoked once the channel is ready for use and TLS has been negotiated or if an error
* is encountered
* shutdown_callback - callback invoked once the channel has shutdown.
* enable_read_back_pressure - controls whether or not back pressure will be applied in the channel
* user_data - arbitrary data to pass back to the various callbacks
* requested_event_loop - if set, the connection will be placed on the requested event loop rather than one
* chosen internally from the bootstrap's associated event loop group. It is an error to pass in an event loop
* that is not associated with the bootstrap's event loop group.
*
* Immediately after the `shutdown_callback` returns, the channel is cleaned up automatically. All callbacks are invoked
* in the thread of the event-loop that the new channel is assigned to.
*
*/
;
/**
* Arguments to setup a server socket listener which will also negotiate and configure TLS.
* This creates a socket listener bound to `host` and 'port' using socket options `options`, and TLS options
* `tls_options`. `incoming_callback` will be invoked once an incoming channel is ready for use and TLS is
* finished negotiating, or if an error is encountered. `shutdown_callback` will be invoked once the channel has
* shutdown. `destroy_callback` will be invoked after the server socket listener is destroyed, and all associated
* connections and channels have finished shutting down. Immediately after the `shutdown_callback` returns, the channel
* is cleaned up automatically. All callbacks are invoked in the thread of the event-loop that listener is assigned to.
*
* Upon shutdown of your application, you'll want to call `aws_server_bootstrap_destroy_socket_listener` with the return
* value from this function.
*
* The socket type in `options` must be AWS_SOCKET_STREAM if tls_options is set.
* DTLS is not currently supported for tls.
*/
;
/**
* Create the client bootstrap.
*/
AWS_IO_API struct aws_client_bootstrap *;
/**
* Increments a client bootstrap's ref count, allowing the caller to take a reference to it.
*
* Returns the same client bootstrap passed in.
*/
AWS_IO_API struct aws_client_bootstrap *;
/**
* Decrements a client bootstrap's ref count. When the ref count drops to zero, the bootstrap will be destroyed.
*/
AWS_IO_API void ;
/**
* When using TLS, if ALPN is used, this callback will be invoked from the channel. The returned handler will be added
* to the channel.
*/
AWS_IO_API int ;
/**
* Sets up a client socket channel.
*/
AWS_IO_API int ;
/**
* Initializes the server bootstrap with `allocator` and `el_group`. This object manages listeners, server connections,
* and channels.
*/
AWS_IO_API struct aws_server_bootstrap *;
/**
* Increments a server bootstrap's ref count, allowing the caller to take a reference to it.
*
* Returns the same server bootstrap passed in.
*/
AWS_IO_API struct aws_server_bootstrap *;
/**
* Decrements a server bootstrap's ref count. When the ref count drops to zero, the bootstrap will be destroyed.
*/
AWS_IO_API void ;
/**
* When using TLS, if ALPN is used, this callback will be invoked from the channel. The returned handler will be added
* to the channel.
*/
AWS_IO_API int ;
/**
* Sets up a server socket listener. If you are planning on using TLS, use
* `aws_server_bootstrap_new_tls_socket_listener` instead. This creates a socket listener bound to `local_endpoint`
* using socket options `options`. `incoming_callback` will be invoked once an incoming channel is ready for use or if
* an error is encountered. `shutdown_callback` will be invoked once the channel has shutdown. `destroy_callback` will
* be invoked after the server socket listener is destroyed, and all associated connections and channels have finished
* shutting down. Immediately after the `shutdown_callback` returns, the channel is cleaned up automatically. All
* callbacks are invoked the thread of the event-loop that the listening socket is assigned to
*
* Upon shutdown of your application, you'll want to call `aws_server_bootstrap_destroy_socket_listener` with the return
* value from this function.
*
* bootstrap_options is copied.
*/
AWS_IO_API struct aws_socket *;
/**
* Shuts down 'listener' and cleans up any resources associated with it. Any incoming channels on `listener` will still
* be active. `destroy_callback` will be invoked after the server socket listener is destroyed, and all associated
* connections and channels have finished shutting down.
*/
AWS_IO_API void ;
/* AWS_IO_CHANNEL_BOOTSTRAP_H */