A version of LWIP, provided for backwards compatibility.

Dependents:   AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more

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 
00013   class TCPListener : public TCPItem {
00014     public:
00015       TCPListener(u16_t port) : _port(port) { 
00016         _pcb = tcp_new();
00017         tcp_arg(this->_pcb, static_cast<void *>(this));
00018       }
00019 
00020       /**
00021        * Function to call when a listener has been connected.
00022        * @param err an error argument (TODO: that is current always ERR_OK?)
00023        * @return ERR_OK: accept the new connection,
00024        *                 any other err_t abortsthe new connection
00025        */
00026       virtual err_t accept(struct tcp_pcb *, err_t err) = 0;
00027     private:
00028       void bind();
00029       
00030       u16_t _port;
00031     friend NetServer;
00032   };
00033 
00034 };
00035 
00036 #endif /* TCPLISTENER_H */