-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathswoole_client_async.cc
547 lines (483 loc) · 19.7 KB
/
swoole_client_async.cc
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
/*
+----------------------------------------------------------------------+
| Swoole |
+----------------------------------------------------------------------+
| This source file is subject to version 2.0 of the Apache license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.apache.org/licenses/LICENSE-2.0.html |
| If you did not receive a copy of the Apache2.0 license and are unable|
| to obtain it through the world-wide-web, please send a note to |
| license@swoole.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Tianfeng Han <mikan.tenny@gmail.com> |
+----------------------------------------------------------------------+
*/
#include "php_swoole_cxx.h"
#include "php_swoole_client.h"
#include "swoole_mqtt.h"
BEGIN_EXTERN_C()
#include "stubs/php_swoole_client_async_arginfo.h"
END_EXTERN_C()
#include "ext/standard/basic_functions.h"
using swoole::network::Client;
using swoole::network::Socket;
static PHP_METHOD(swoole_client_async, __construct);
static PHP_METHOD(swoole_client_async, __destruct);
static PHP_METHOD(swoole_client_async, connect);
static PHP_METHOD(swoole_client_async, sleep);
static PHP_METHOD(swoole_client_async, wakeup);
#ifdef SW_USE_OPENSSL
static PHP_METHOD(swoole_client_async, enableSSL);
#endif
static PHP_METHOD(swoole_client_async, isConnected);
static PHP_METHOD(swoole_client_async, close);
static PHP_METHOD(swoole_client_async, on);
static void client_onConnect(Client *cli);
static void client_onReceive(Client *cli, const char *data, size_t length);
static void client_onClose(Client *cli);
static void client_onError(Client *cli);
static void client_onBufferFull(Client *cli);
static void client_onBufferEmpty(Client *cli);
zend_class_entry *swoole_client_async_ce;
static zend_object_handlers swoole_client_async_handlers;
void php_swoole_client_async_free_object(ClientObject *client_obj) {
if (client_obj->async->onConnect) {
sw_callable_free(client_obj->async->onConnect);
}
if (client_obj->async->onReceive) {
sw_callable_free(client_obj->async->onReceive);
}
if (client_obj->async->onClose) {
sw_callable_free(client_obj->async->onClose);
}
if (client_obj->async->onError) {
sw_callable_free(client_obj->async->onError);
}
if (client_obj->async->onBufferFull) {
sw_callable_free(client_obj->async->onBufferFull);
}
if (client_obj->async->onBufferEmpty) {
sw_callable_free(client_obj->async->onBufferEmpty);
}
#ifdef SW_USE_OPENSSL
if (client_obj->async->onSSLReady) {
sw_callable_free(client_obj->async->onSSLReady);
}
#endif
delete client_obj->async;
}
static sw_inline void client_execute_callback(zval *zobject, enum php_swoole_client_callback_type type) {
auto client_obj = php_swoole_client_fetch_object(zobject);
const char *callback_name;
zend::Callable *cb;
switch (type) {
case SW_CLIENT_CB_onConnect:
callback_name = "onConnect";
cb = client_obj->async->onConnect;
break;
case SW_CLIENT_CB_onError:
callback_name = "onError";
cb = client_obj->async->onError;
break;
case SW_CLIENT_CB_onClose:
callback_name = "onClose";
cb = client_obj->async->onClose;
break;
case SW_CLIENT_CB_onBufferFull:
callback_name = "onBufferFull";
cb = client_obj->async->onBufferFull;
break;
case SW_CLIENT_CB_onBufferEmpty:
callback_name = "onBufferEmpty";
cb = client_obj->async->onBufferEmpty;
break;
#ifdef SW_USE_OPENSSL
case SW_CLIENT_CB_onSSLReady:
callback_name = "onSSLReady";
cb = client_obj->async->onSSLReady;
break;
#endif
default:
abort();
return;
}
if (!cb) {
php_swoole_fatal_error(E_WARNING, "%s has no %s callback", SW_Z_OBJCE_NAME_VAL_P(zobject), callback_name);
return;
}
if (UNEXPECTED(sw_zend_call_function_ex2(NULL, cb->ptr(), 1, zobject, NULL) != SUCCESS)) {
php_swoole_fatal_error(E_WARNING, "%s->%s handler error", SW_Z_OBJCE_NAME_VAL_P(zobject), callback_name);
}
}
// clang-format off
static const zend_function_entry swoole_client_async_methods[] = {
PHP_ME(swoole_client_async, __construct, arginfo_class_Swoole_Async_Client___construct, ZEND_ACC_PUBLIC)
PHP_ME(swoole_client_async, __destruct, arginfo_class_Swoole_Async_Client___destruct, ZEND_ACC_PUBLIC)
PHP_ME(swoole_client_async, connect, arginfo_class_Swoole_Async_Client_connect, ZEND_ACC_PUBLIC)
PHP_ME(swoole_client_async, sleep, arginfo_class_Swoole_Async_Client_sleep, ZEND_ACC_PUBLIC)
PHP_ME(swoole_client_async, wakeup, arginfo_class_Swoole_Async_Client_wakeup, ZEND_ACC_PUBLIC)
PHP_MALIAS(swoole_client_async, pause, sleep, arginfo_class_Swoole_Async_Client_sleep, ZEND_ACC_PUBLIC)
PHP_MALIAS(swoole_client_async, resume, wakeup, arginfo_class_Swoole_Async_Client_wakeup, ZEND_ACC_PUBLIC)
#ifdef SW_USE_OPENSSL
PHP_ME(swoole_client_async, enableSSL, arginfo_class_Swoole_Async_Client_enableSSL, ZEND_ACC_PUBLIC)
#endif
PHP_ME(swoole_client_async, isConnected, arginfo_class_Swoole_Async_Client_isConnected, ZEND_ACC_PUBLIC)
PHP_ME(swoole_client_async, close, arginfo_class_Swoole_Async_Client_close, ZEND_ACC_PUBLIC)
PHP_ME(swoole_client_async, on, arginfo_class_Swoole_Async_Client_on, ZEND_ACC_PUBLIC)
PHP_FE_END
};
// clang-format on
void php_swoole_client_async_minit(int module_number) {
SW_INIT_CLASS_ENTRY_EX(
swoole_client_async, "Swoole\\Async\\Client", nullptr, swoole_client_async_methods, swoole_client);
SW_SET_CLASS_NOT_SERIALIZABLE(swoole_client_async);
SW_SET_CLASS_CLONEABLE(swoole_client_async, sw_zend_class_clone_deny);
SW_SET_CLASS_UNSET_PROPERTY_HANDLER(swoole_client_async, sw_zend_class_unset_property_deny);
zend_declare_property_null(swoole_client_async_ce, ZEND_STRL("onConnect"), ZEND_ACC_PRIVATE);
zend_declare_property_null(swoole_client_async_ce, ZEND_STRL("onError"), ZEND_ACC_PRIVATE);
zend_declare_property_null(swoole_client_async_ce, ZEND_STRL("onReceive"), ZEND_ACC_PRIVATE);
zend_declare_property_null(swoole_client_async_ce, ZEND_STRL("onClose"), ZEND_ACC_PRIVATE);
zend_declare_property_null(swoole_client_async_ce, ZEND_STRL("onBufferFull"), ZEND_ACC_PRIVATE);
zend_declare_property_null(swoole_client_async_ce, ZEND_STRL("onBufferEmpty"), ZEND_ACC_PRIVATE);
#ifdef SW_USE_OPENSSL
zend_declare_property_null(swoole_client_async_ce, ZEND_STRL("onSSLReady"), ZEND_ACC_PRIVATE);
#endif
}
static void client_onReceive(Client *cli, const char *data, size_t length) {
zval *zobject = (zval *) cli->object;
auto client_obj = php_swoole_client_fetch_object(zobject);
zend_fcall_info_cache *fci_cache = client_obj->async->onReceive->ptr();
zval args[2];
args[0] = *zobject;
ZVAL_STRINGL(&args[1], data, length);
if (UNEXPECTED(sw_zend_call_function_ex2(NULL, fci_cache, 2, args, NULL) != SUCCESS)) {
php_swoole_fatal_error(E_WARNING, "%s->onReceive handler error", SW_Z_OBJCE_NAME_VAL_P(zobject));
}
zval_ptr_dtor(&args[1]);
}
static void client_onConnect(Client *cli) {
zval *zobject = (zval *) cli->object;
#ifdef SW_USE_OPENSSL
if (cli->ssl_wait_handshake) {
cli->ssl_wait_handshake = 0;
client_execute_callback(zobject, SW_CLIENT_CB_onSSLReady);
return;
}
#endif
client_execute_callback(zobject, SW_CLIENT_CB_onConnect);
}
static void client_onClose(Client *cli) {
zval *zobject = (zval *) cli->object;
client_execute_callback(zobject, SW_CLIENT_CB_onClose);
zval_ptr_dtor(zobject);
}
static void client_onError(Client *cli) {
zval *zobject = (zval *) cli->object;
zend_update_property_long(swoole_client_async_ce, Z_OBJ_P(zobject), ZEND_STRL("errCode"), swoole_get_last_error());
client_execute_callback(zobject, SW_CLIENT_CB_onError);
zval_ptr_dtor(zobject);
}
static void client_onBufferFull(Client *cli) {
zval *zobject = (zval *) cli->object;
client_execute_callback(zobject, SW_CLIENT_CB_onBufferFull);
}
static void client_onBufferEmpty(Client *cli) {
zval *zobject = (zval *) cli->object;
client_execute_callback(zobject, SW_CLIENT_CB_onBufferEmpty);
}
static PHP_METHOD(swoole_client_async, __construct) {
zend_long type = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &type) == FAILURE) {
zend_throw_error(NULL, "socket type param is required");
RETURN_FALSE;
}
int client_type = php_swoole_get_socket_type(type);
if (client_type < SW_SOCK_TCP || client_type > SW_SOCK_UNIX_DGRAM) {
const char *space, *class_name = get_active_class_name(&space);
zend_type_error("%s%s%s() expects parameter %d to be client type, unknown type " ZEND_LONG_FMT " given",
class_name,
space,
get_active_function_name(),
1,
type);
RETURN_FALSE;
}
php_swoole_check_reactor();
zend_update_property_long(swoole_client_ce, SW_Z8_OBJ_P(ZEND_THIS), ZEND_STRL("type"), type);
RETURN_TRUE;
}
static PHP_METHOD(swoole_client_async, __destruct) {
SW_PREVENT_USER_DESTRUCT();
Client *cli = (Client *) php_swoole_client_get_cli(ZEND_THIS);
if (cli && cli->active) {
sw_zend_call_method_with_0_params(ZEND_THIS, swoole_client_async_ce, NULL, "close", NULL);
}
}
static Client *php_swoole_client_async_new(zval *zobject, char *host, int host_len, int port) {
zval *ztype = sw_zend_read_property_ex(Z_OBJCE_P(zobject), zobject, SW_ZSTR_KNOWN(SW_ZEND_STR_TYPE), 0);
if (ztype == nullptr || ZVAL_IS_NULL(ztype)) {
php_swoole_fatal_error(E_ERROR, "failed to get swoole_client->type");
return nullptr;
}
long type = Z_LVAL_P(ztype);
int client_type = php_swoole_get_socket_type(type);
if ((client_type == SW_SOCK_TCP || client_type == SW_SOCK_TCP6) && (port <= 0 || port > SW_CLIENT_MAX_PORT)) {
php_swoole_fatal_error(E_WARNING, "The port is invalid");
swoole_set_last_error(SW_ERROR_INVALID_PARAMS);
return nullptr;
}
Client *cli = new Client(php_swoole_get_socket_type(type), true);
if (cli->socket == nullptr) {
php_swoole_sys_error(E_WARNING, "Client_create() failed");
zend_update_property_long(Z_OBJCE_P(zobject), SW_Z8_OBJ_P(zobject), ZEND_STRL("errCode"), errno);
delete cli;
return nullptr;
}
zend_update_property_long(Z_OBJCE_P(zobject), SW_Z8_OBJ_P(zobject), ZEND_STRL("sock"), cli->socket->fd);
#ifdef SW_USE_OPENSSL
if (type & SW_SOCK_SSL) {
cli->enable_ssl_encrypt();
}
#endif
return cli;
}
static PHP_METHOD(swoole_client_async, connect) {
char *host;
size_t host_len;
zend_long port = 0;
double timeout = SW_CLIENT_CONNECT_TIMEOUT;
zend_long sock_flag = 0;
ZEND_PARSE_PARAMETERS_START(1, 4)
Z_PARAM_STRING(host, host_len)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(port)
Z_PARAM_DOUBLE(timeout)
Z_PARAM_LONG(sock_flag)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (host_len == 0) {
php_swoole_fatal_error(E_WARNING, "The host is empty");
RETURN_FALSE;
}
auto client_obj = php_swoole_client_fetch_object(ZEND_THIS);
if (client_obj->cli) {
php_swoole_fatal_error(E_WARNING, "connection to the server has already been established");
RETURN_FALSE;
}
if (!client_obj->async) {
php_swoole_fatal_error(E_WARNING, "async client is not initialized");
RETURN_FALSE;
}
auto cli = php_swoole_client_async_new(ZEND_THIS, host, host_len, port);
if (cli == NULL) {
RETURN_FALSE;
}
zval *zset = sw_zend_read_property(swoole_client_async_ce, ZEND_THIS, ZEND_STRL("setting"), 0);
if (zset && ZVAL_IS_ARRAY(zset)) {
php_swoole_client_check_setting(cli, zset);
}
if (!client_obj->async->onReceive) {
php_swoole_fatal_error(E_ERROR, "no 'onReceive' callback function");
RETURN_FALSE;
}
if (cli->get_socket()->is_stream()) {
if (!client_obj->async->onConnect) {
php_swoole_fatal_error(E_ERROR, "no 'onConnect' callback function");
RETURN_FALSE;
}
if (!client_obj->async->onError) {
php_swoole_fatal_error(E_ERROR, "no 'onError' callback function");
RETURN_FALSE;
}
if (!client_obj->async->onClose) {
php_swoole_fatal_error(E_ERROR, "no 'onClose' callback function");
RETURN_FALSE;
}
cli->onConnect = client_onConnect;
cli->onClose = client_onClose;
cli->onError = client_onError;
cli->onReceive = client_onReceive;
if (client_obj->async->onBufferFull) {
cli->onBufferFull = client_onBufferFull;
}
if (client_obj->async->onBufferEmpty) {
cli->onBufferEmpty = client_onBufferEmpty;
}
} else {
if (client_obj->async->onConnect) {
cli->onConnect = client_onConnect;
}
if (client_obj->async->onClose) {
cli->onClose = client_onClose;
}
if (client_obj->async->onError) {
cli->onError = client_onError;
}
cli->onReceive = client_onReceive;
}
client_obj->async->_zobject = *ZEND_THIS;
client_obj->cli = cli;
cli->object = &client_obj->async->_zobject;
Z_TRY_ADDREF_P(ZEND_THIS);
// nonblock async
if (cli->connect(cli, host, port, timeout, sock_flag) < 0) {
if (errno == 0) {
auto error = swoole_get_last_error();
if (error == SW_ERROR_DNSLOOKUP_RESOLVE_FAILED) {
php_swoole_error(E_WARNING,
"connect to server[%s:%d] failed. Error: %s[%d]",
host,
(int) port,
swoole_strerror(error),
error);
}
zend_update_property_long(swoole_client_async_ce, Z_OBJ_P(ZEND_THIS), ZEND_STRL("errCode"), error);
} else {
php_swoole_sys_error(E_WARNING, "connect to server[%s:%d] failed", host, (int) port);
zend_update_property_long(swoole_client_async_ce, Z_OBJ_P(ZEND_THIS), ZEND_STRL("errCode"), errno);
}
Client *cli = (Client *) php_swoole_client_get_cli(ZEND_THIS);
if (cli && cli->onError == NULL) {
php_swoole_client_free(ZEND_THIS, cli);
zval_ptr_dtor(ZEND_THIS);
}
RETURN_FALSE;
}
RETURN_TRUE;
}
static PHP_METHOD(swoole_client_async, isConnected) {
Client *cli = (Client *) php_swoole_client_get_cli(ZEND_THIS);
if (!cli) {
RETURN_FALSE;
}
if (!cli->socket) {
RETURN_FALSE;
}
RETURN_BOOL(cli->active);
}
static PHP_METHOD(swoole_client_async, close) {
int ret = 1;
Client *cli = (Client *) php_swoole_client_get_cli(ZEND_THIS);
if (!cli || !cli->socket) {
php_swoole_fatal_error(E_WARNING, "client is not connected to the server");
RETURN_FALSE;
}
if (cli->closed) {
php_swoole_error(E_WARNING, "client socket is closed");
RETURN_FALSE;
}
if (cli->async && cli->active == 0) {
zval *zobject = ZEND_THIS;
zval_ptr_dtor(zobject);
}
ret = cli->close();
php_swoole_client_free(ZEND_THIS, cli);
SW_CHECK_RETURN(ret);
}
static PHP_METHOD(swoole_client_async, on) {
char *cb_name;
size_t cb_name_len;
zval *zcallback;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sz", &cb_name, &cb_name_len, &zcallback) == FAILURE) {
RETURN_FALSE;
}
auto client_obj = php_swoole_client_fetch_object(ZEND_THIS);
auto cb = sw_callable_create(zcallback);
if (!cb) {
return;
}
if (!client_obj->async) {
client_obj->async = new AsyncClientObject();
}
if (strncasecmp("connect", cb_name, cb_name_len) == 0) {
zend_update_property(swoole_client_async_ce, Z_OBJ_P(ZEND_THIS), ZEND_STRL("onConnect"), zcallback);
if (client_obj->async->onConnect) {
sw_callable_free(client_obj->async->onConnect);
}
client_obj->async->onConnect = cb;
} else if (strncasecmp("receive", cb_name, cb_name_len) == 0) {
zend_update_property(swoole_client_async_ce, Z_OBJ_P(ZEND_THIS), ZEND_STRL("onReceive"), zcallback);
if (client_obj->async->onReceive) {
sw_callable_free(client_obj->async->onReceive);
}
client_obj->async->onReceive = cb;
} else if (strncasecmp("close", cb_name, cb_name_len) == 0) {
zend_update_property(swoole_client_async_ce, Z_OBJ_P(ZEND_THIS), ZEND_STRL("onClose"), zcallback);
if (client_obj->async->onClose) {
sw_callable_free(client_obj->async->onClose);
}
client_obj->async->onClose = cb;
} else if (strncasecmp("error", cb_name, cb_name_len) == 0) {
zend_update_property(swoole_client_async_ce, Z_OBJ_P(ZEND_THIS), ZEND_STRL("onError"), zcallback);
if (client_obj->async->onError) {
sw_callable_free(client_obj->async->onError);
}
client_obj->async->onError = cb;
} else if (strncasecmp("bufferFull", cb_name, cb_name_len) == 0) {
zend_update_property(swoole_client_async_ce, Z_OBJ_P(ZEND_THIS), ZEND_STRL("onBufferFull"), zcallback);
if (client_obj->async->onBufferFull) {
sw_callable_free(client_obj->async->onBufferFull);
}
client_obj->async->onBufferFull = cb;
} else if (strncasecmp("bufferEmpty", cb_name, cb_name_len) == 0) {
zend_update_property(swoole_client_async_ce, Z_OBJ_P(ZEND_THIS), ZEND_STRL("onBufferEmpty"), zcallback);
if (client_obj->async->onBufferEmpty) {
sw_callable_free(client_obj->async->onBufferEmpty);
}
client_obj->async->onBufferEmpty = cb;
} else {
php_swoole_fatal_error(E_WARNING, "Unknown event callback type name '%s'", cb_name);
RETURN_FALSE;
}
RETURN_TRUE;
}
static PHP_METHOD(swoole_client_async, sleep) {
Client *cli = php_swoole_client_get_cli_safe(ZEND_THIS);
if (!cli) {
RETURN_FALSE;
}
SW_CHECK_RETURN(cli->sleep());
}
static PHP_METHOD(swoole_client_async, wakeup) {
Client *cli = php_swoole_client_get_cli_safe(ZEND_THIS);
if (!cli) {
RETURN_FALSE;
}
SW_CHECK_RETURN(cli->wakeup());
}
#ifdef SW_USE_OPENSSL
static PHP_METHOD(swoole_client_async, enableSSL) {
zval *zcallback = nullptr;
ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
Z_PARAM_ZVAL(zcallback)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (zcallback == nullptr) {
zend_throw_exception(swoole_exception_ce, "require `onSslReady` callback", SW_ERROR_INVALID_PARAMS);
RETURN_FALSE;
}
Client *cli = php_swoole_client_get_cli_safe(ZEND_THIS);
if (!cli) {
RETURN_FALSE;
}
if (!php_swoole_client_enable_ssl_encryption(cli, ZEND_THIS)) {
RETURN_FALSE;
}
auto client_obj = php_swoole_client_fetch_object(ZEND_THIS);
if (swoole_event_set(cli->socket, SW_EVENT_WRITE) < 0) {
RETURN_FALSE;
}
if (client_obj->async->onSSLReady) {
sw_callable_free(client_obj->async->onSSLReady);
}
auto cb = sw_callable_create(zcallback);
if (!cb) {
RETURN_FALSE;
}
zend_update_property(swoole_client_async_ce, Z_OBJ_P(ZEND_THIS), ZEND_STRL("onSSLReady"), zcallback);
client_obj->async->onSSLReady = cb;
cli->ssl_wait_handshake = 1;
cli->socket->ssl_state = SW_SSL_STATE_WAIT_STREAM;
RETURN_TRUE;
}
#endif