Machine Vision Status TCP Server
Dependencies: C12832 EthernetInterface mbed-rtos mbed ConfigFile
TcpDaemon.h
- Committer:
- dwini
- Date:
- 2015-03-05
- Revision:
- 2:a8eebf64cd3e
- Parent:
- 1:8efef658d90b
- Child:
- 3:254a2671a8e3
File content as of revision 2:a8eebf64cd3e:
#include "EthernetInterface.h" #ifndef TCP_DAEMON_HEADER #define TCP_DAEMON_HEADER #include "mbed.h" #define MAX_BACKLOG 1 namespace MachineVision{ class TcpDaemon{ public: const static int BUFFER_SIZE = 512; const static int TCP_TIMEOUT = 250; const static int MAX_READ_TIMEOUTS = 10; // Maximum number of times to retry to read for rest of message private: int server_port; TCPSocketServer server; TCPSocketConnection client; char buffer[BUFFER_SIZE+1]; bool keepListening; DigitalOut receive_led; public: /* * TcpDaemon constructor * * @server_port the port the daemon will be listening on */ TcpDaemon(int server_port, PinName receive_led_pin); /* * Make the daemon start listening for incoming connections */ void startListening(); private: /* * Bind to server socket * * @return true on success */ bool bindSocket(); /* * Listen for incoming connections */ void doListen(); }; } #endif