Embedded WebSockets Experiment

Dependencies:   mbed MD5

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TCPListener.h Source File

TCPListener.h

00001 #ifndef TCPLISTENER_H
00002 #define TCPLISTENER_H
00003 
00004 #include "TCPItem.h"
00005 
00006 #include "arch/cc.h"
00007 #include "lwip/err.h"
00008 #include "lwip/tcp.h"
00009 
00010 namespace mbed {
00011   class NetServer;
00012   class TCPConnection;
00013 
00014   class TCPListener : public TCPItem {
00015     public:
00016       TCPListener(u16_t port) : _port(port) { 
00017       }
00018 
00019       virtual ~TCPListener() {}
00020 
00021       void bind();
00022     protected:
00023       /**
00024        * Function to call when a listener has been connected.
00025        * @param err an error argument (TODO: that is current always ERR_OK?)
00026        * @return ERR_OK: accept the new connection,
00027        *                 any other err_t abortsthe new connection
00028        */
00029       virtual err_t accept(struct tcp_pcb *, err_t err) = 0;
00030       
00031       u16_t _port;
00032     private:
00033       static err_t accept_callback(void *arg, struct tcp_pcb *newpcb, err_t err);
00034     friend NetServer;
00035     friend TCPConnection;
00036     
00037   };
00038 
00039 };
00040 
00041 #endif /* TCPLISTENER_H */