Close / clean up a socket if connect fails.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3920 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-07-09 14:14:48 +00:00
parent ff2a0f0c3f
commit fe5a6033ef
2 changed files with 30 additions and 1 deletions

View File

@ -485,7 +485,32 @@ static void _test_socket(const tf_test_options_t* options)
" s2.shutdown();\n"
" });\n"
"}).catch(function(e) {\n"
" printf('caught');\n"
" print('caught');\n"
" print(e);\n"
"});\n"
"var s3 = new Socket();\n"
"print('connecting s3');\n"
"print('before connect', s3.isConnected);\n"
"s3.onError(function(e) {\n"
" print('error');\n"
" print(e);\n"
"});\n"
"print('noDelay', s3.noDelay);\n"
"s3.noDelay = true;\n"
"s3.connect('0.0.0.0', 443).then(function() {\n"
" print('connected');\n"
" s3.read(function(data) {\n"
" print('read', data ? data.length : null);\n"
" });\n"
" return s3.startTls();\n"
"}).then(function() {\n"
" print('ready');\n"
" print(s3.peerName);\n"
" s3.write('GET / HTTP/1.0\\r\\nConnection: close\\r\\n\\r\\n').then(function() {\n"
" s3.shutdown();\n"
" });\n"
"}).catch(function(e) {\n"
" print('caught');\n"
" print(e);\n"
"});\n");
fclose(file);