Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TCPServer constructor #2594

Merged
merged 1 commit into from
Sep 10, 2016
Merged

Conversation

svastm
Copy link
Contributor

@svastm svastm commented Aug 31, 2016

This PR do

  • Avoid a call to the protected method get_stack() which cause a build fail.
  • Remove the constructor definition TCPServer(NetworkStack *stack)
    because it has no implementation.

To fix the following error

> mbed compile -m NUCLEO_F746ZG -t ARM
Building project mbed-os (NUCLEO_F746ZG, ARM)
Scan: .
Scan: FEATURE_BLE
Scan: FEATURE_CLIENT
Scan: FEATURE_COMMON_PAL
Scan: FEATURE_UVISOR
Scan: FEATURE_IPV4
Scan: FEATURE_IPV6
Scan: FEATURE_STORAGE
Scan: mbed
Scan: env
Compile: main.cpp
[Warning] ip_addr.h@53,0:  #3135-D: attribute does not apply to any entity
[Warning] ip_addr.h@74,0:  #3135-D: attribute does not apply to any entity
[Error] TCPServer.h@50,0:  #265-D: function "EthernetInterface::get_stack" (declared at line 59 of "./mbed-os/features/net/FEATURE_IPV4/lwip-interface/EthernetInterface.h") is inaccessible
[ERROR] "./mbed-os/features/net/FEATURE_IPV4/lwip-interface/lwip/include/ipv4/lwip/ip_addr.h", line 53: Warning:  #3135-D: attribute does not apply to any entity
"./mbed-os/features/net/FEATURE_IPV4/lwip-interface/lwip/include/ipv4/lwip/ip_addr.h", line 74: Warning:  #3135-D: attribute does not apply to any entity
"./mbed-os/features/net/network-socket/TCPServer.h", line 50: Error:  #265-D: function "EthernetInterface::get_stack" (declared at line 59 of "./mbed-os/features/net/FEATURE_IPV4/lwip-interface/EthernetInterface.h") is inaccessible
          detected during instantiation of "TCPServer::TCPServer(IF *) [with IF=EthernetInterface]" at line 36 of ".\main.cpp"
.\main.cpp: 2 warnings, 1 error

with this code

#if !FEATURE_IPV4
    #error [NOT_SUPPORTED] IPV4 not supported for this target
#endif

#include "mbed.h"
#include "EthernetInterface.h"
#include "TCPServer.h"
#include "TCPSocket.h"

#define HTTP_STATUS_LINE "HTTP/1.0 200 OK"
#define HTTP_HEADER_FIELDS "Content-Type: text/html; charset=utf-8"
#define HTTP_MESSAGE_BODY ""                                     \
"<html>" "\r\n"                                                  \
"  <body style=\"display:flex;text-align:center\">" "\r\n"       \
"    <div style=\"margin:auto\">" "\r\n"                         \
"      <h1>Hello World</h1>" "\r\n"                              \
"      <p>It works !</p>" "\r\n"                                 \
"    </div>" "\r\n"                                              \
"  </body>" "\r\n"                                               \
"</html>"

#define HTTP_RESPONSE HTTP_STATUS_LINE "\r\n"   \
                      HTTP_HEADER_FIELDS "\r\n" \
                      "\r\n"                    \
                      HTTP_MESSAGE_BODY "\r\n"

int main()
{
    printf("Basic HTTP server example\n");

    EthernetInterface eth;
    eth.connect();

    printf("The target IP address is '%s'\n", eth.get_ip_address());

    TCPServer srv(&eth);
    TCPSocket clt_sock;
    SocketAddress clt_addr;

    /* Bind the HTTP port (TCP 80) to the server */
    srv.bind(eth.get_ip_address(), 80);

    /* Can handle 5 simultaneous connections */
    srv.listen(5);

    while (true) {
        srv.accept(&clt_sock, &clt_addr);
        printf("accept %s:%d\n", clt_addr.get_ip_address(), clt_addr.get_port());
        clt_sock.send(HTTP_RESPONSE, strlen(HTTP_RESPONSE));
    }
}

 - Avoid a call to the protected method `get_stack()` which cause a build fail.
 - Remove the constructor definition `TCPServer(NetworkStack *stack)`
   because it has no implementation.
@0xc0170
Copy link
Contributor

0xc0170 commented Aug 31, 2016

cc @geky

@geky
Copy link
Contributor

geky commented Aug 31, 2016

+1 this looks great, thanks for creating this patch!

Most users are using the open member function, which explains why this problem hasn't been reported yet. LGTM

@sg- sg- added the needs: CI label Sep 9, 2016
@sg-
Copy link
Contributor

sg- commented Sep 9, 2016

/morph test

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 823

All builds and test passed!

@sg- sg- merged commit 5c30c0f into ARMmbed:master Sep 10, 2016
@svastm svastm deleted the fix_tcp_server_constructor branch September 16, 2016 09:25
theotherjimmy added a commit that referenced this pull request Sep 19, 2016
Release mbed-os-5.1.4

Changes:

New Targets:
2504: [Disco_F769NI] adding new target [#2504]
2654: DELTA_DFBM_NQ620 platform porting [#2654]
2615: [MTM_MTCONNECT04S] Added support for MTM_MTCONNECT04S [#2615]
2548: Nucleof303ze [#2548]

Fixes:

2678: Fixing NCS36510 compile on Linux #2678
2657: [MAX326xx] Removed echoing of characters and carriage return. #2657
2651: Use lp_timer to count time in the deepsleep tests #2651
2645: NUCLEO_F446ZE - Enable mbed5 release version #2645
2643: Fix thread self termination #2643
2634: Updated USBHost for library changes #2634
2633: Updated USBDevice to use Callback #2633
2630: Test names not dependent on disk location of root #2630
2624: CFSTORE Bugfix for realloc() moving KV area and cfstore_file_t data structures not being updated correctly #2624
2623: DISCO_L476VG - Add Serial Flow Control pins + add SERIAL_FC macro #2623
2617: STM32F2xx - Enable Serial Flow Control #2617
2613: Correctly providing directories to build_apis #2613
2607: Fix uvisor memory tracing #2607
2604: Tools - Fix fill section size variation #2604
2601: Adding ON Semiconductor copyright notice to source and header files. #2601
2597: [HAL] Fixed "intrinsic is deprecated" warnings #2597
2596: [HAL] Improve memory tracer #2596
2594: Fix TCPServer constructor #2594
2593: Add app config command line switch for test and make #2593
2589: [NUC472] Fix heap configuration error with armcc #2589
2588: Timing tests drift refactor #2588
2587: add PTEx pins as option for SPI on Hexiwear - for SD Card Interface #2587
2584: Set size of callback irq array to IrqCnt #2584
2583: github issue and PR templates #2583
2582: [GCC_CR] fix runtime hang for baremetal build #2582
2580: lwip - Add check for previously-bound socket #2580
2579: lwip - Fix handling of max sockets in socket_accept #2579
2578: Fix double free in NanostackInterface #2578
2576: Add smoke test that builds example programs with mbed-cli #2576
2575: tools-config! -  Allow an empty or mal-formed config to be passed to the config system #2575
2562: Fix GCC lazy init race condition and add test #2562
2559: [utest]: Allow the linker to remove any part of utest if not used #2559
2545: Added define guards for SEQUENTIAL_FLASH_JOURNAL_MAX_LOGGED_BLOBS so  #2545
2538: STM32F4xx - Add support of ADC internal channels (Temp, VRef, VBat) #2538
2521: [NUCLEO_F207ZG] Add MBED5 capability #2521
2514: Updated FlexCan and SAI SDK drivers #2514
2487: Runtime dynamic memory tracing #2487
2442: Malloc heap info #2442
2419: [STM32F1] Add asynchronous serial #2419
2393: [tools] Prevent trace-backs from incomplete args #2393
2245: Refactor export subsystem #2245
2130: stm32 : reduce number of device.h files #2130
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants