Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
tcpsocket_send_timeout.cpp
00001 /* 00002 * Copyright (c) 2018, ARM Limited, All Rights Reserved 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00006 * not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #include "mbed.h" 00019 #include "TCPSocket.h" 00020 #include "greentea-client/test_env.h" 00021 #include "unity/unity.h" 00022 #include "utest.h" 00023 #include "tcp_tests.h" 00024 00025 using namespace utest::v1; 00026 00027 void TCPSOCKET_SEND_TIMEOUT() 00028 { 00029 TCPSocket sock; 00030 if (tcpsocket_connect_to_discard_srv(sock) != NSAPI_ERROR_OK ) { 00031 TEST_FAIL(); 00032 return; 00033 } 00034 00035 int err; 00036 Timer timer; 00037 static const char tx_buffer[] = {'h', 'e', 'l', 'l', 'o'}; 00038 for (int i = 0; i < 10; i++) { 00039 timer.reset(); 00040 timer.start(); 00041 err = sock.send(tx_buffer, sizeof(tx_buffer)); 00042 timer.stop(); 00043 if ((err == sizeof(tx_buffer)) && 00044 (timer.read_ms() <= 800)) { 00045 continue; 00046 } 00047 TEST_FAIL(); 00048 break; 00049 } 00050 00051 TEST_ASSERT_EQUAL(NSAPI_ERROR_OK , sock.close()); 00052 }
Generated on Tue Aug 9 2022 00:37:21 by
1.7.2