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.
TCPEchoHandler.h
00001 #ifndef TCP_ECHO_HANDLER_H 00002 #define TCP_ECHO_HANDLER_H 00003 00004 #include "mbed.h" 00005 #include "TCPSocket.h" 00006 #include "netservice.h" 00007 00008 // Constant: ECHO_TIMOUT 00009 // The timeout period for inactivity in milliseconds 00010 #define ECHO_TIMEOUT 5000 00011 00012 /* 00013 Class: TCPEchoHandler 00014 A class instantiated to handle the incoming TCP client connection 00015 Extends NetService to hook into the TCP/IP stack's polling 00016 and destruction service 00017 */ 00018 class TCPEchoHandler : public NetService { 00019 public: 00020 // Constructor: TCPEchoHandler 00021 // Setup and handle the incoming connection 00022 TCPEchoHandler(TCPSocket*, char*); 00023 virtual ~TCPEchoHandler(); 00024 private: 00025 // Variable: clientSocket 00026 // The incoming TCP socket from the client 00027 TCPSocket* clientSocket; 00028 // Variable: closed 00029 // A marker to say whether this socket is already closed 00030 int closed; 00031 // Variable: timeoutWatchdog 00032 // A timer to countdown from during inactivity and close 00033 // dormant connections 00034 Timeout timeoutWatchdog; 00035 00036 // Function: onNetTcpSocketEvent 00037 // The callback function called by the network stack whenever an 00038 // event occurs on the TCP socket 00039 // Parameter: e - The event that has occurred 00040 void onTCPSocketEvent(TCPSocketEvent e); 00041 // Function: close 00042 // Closes the client socket and marks this class as done with 00043 // for the TCP/IP stack to destroy 00044 virtual void close(); 00045 // Function: setTimeout 00046 // Parameter: timeout - The length of time to wait for more activity in milliseconds 00047 void setTimeout(unsigned int timeout); 00048 // Function: onTimeout 00049 // The handler called by the timeout watchdog to close the connection when timed out 00050 void onTimeout(); 00051 }; 00052 00053 #endif
Generated on Wed Jul 13 2022 09:03:52 by
