John Lowe
/
WebSockets2
Embedded WebSockets Experiment
Core/TCPListener.h@0:6dee052a3fa4, 2011-07-26 (annotated)
- Committer:
- nandgate
- Date:
- Tue Jul 26 05:30:53 2011 +0000
- Revision:
- 0:6dee052a3fa4
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nandgate | 0:6dee052a3fa4 | 1 | #ifndef TCPLISTENER_H |
nandgate | 0:6dee052a3fa4 | 2 | #define TCPLISTENER_H |
nandgate | 0:6dee052a3fa4 | 3 | |
nandgate | 0:6dee052a3fa4 | 4 | #include "TCPItem.h" |
nandgate | 0:6dee052a3fa4 | 5 | |
nandgate | 0:6dee052a3fa4 | 6 | #include "arch/cc.h" |
nandgate | 0:6dee052a3fa4 | 7 | #include "lwip/err.h" |
nandgate | 0:6dee052a3fa4 | 8 | #include "lwip/tcp.h" |
nandgate | 0:6dee052a3fa4 | 9 | |
nandgate | 0:6dee052a3fa4 | 10 | namespace mbed { |
nandgate | 0:6dee052a3fa4 | 11 | class NetServer; |
nandgate | 0:6dee052a3fa4 | 12 | class TCPConnection; |
nandgate | 0:6dee052a3fa4 | 13 | |
nandgate | 0:6dee052a3fa4 | 14 | class TCPListener : public TCPItem { |
nandgate | 0:6dee052a3fa4 | 15 | public: |
nandgate | 0:6dee052a3fa4 | 16 | TCPListener(u16_t port) : _port(port) { |
nandgate | 0:6dee052a3fa4 | 17 | } |
nandgate | 0:6dee052a3fa4 | 18 | |
nandgate | 0:6dee052a3fa4 | 19 | virtual ~TCPListener() {} |
nandgate | 0:6dee052a3fa4 | 20 | |
nandgate | 0:6dee052a3fa4 | 21 | void bind(); |
nandgate | 0:6dee052a3fa4 | 22 | protected: |
nandgate | 0:6dee052a3fa4 | 23 | /** |
nandgate | 0:6dee052a3fa4 | 24 | * Function to call when a listener has been connected. |
nandgate | 0:6dee052a3fa4 | 25 | * @param err an error argument (TODO: that is current always ERR_OK?) |
nandgate | 0:6dee052a3fa4 | 26 | * @return ERR_OK: accept the new connection, |
nandgate | 0:6dee052a3fa4 | 27 | * any other err_t abortsthe new connection |
nandgate | 0:6dee052a3fa4 | 28 | */ |
nandgate | 0:6dee052a3fa4 | 29 | virtual err_t accept(struct tcp_pcb *, err_t err) = 0; |
nandgate | 0:6dee052a3fa4 | 30 | |
nandgate | 0:6dee052a3fa4 | 31 | u16_t _port; |
nandgate | 0:6dee052a3fa4 | 32 | private: |
nandgate | 0:6dee052a3fa4 | 33 | static err_t accept_callback(void *arg, struct tcp_pcb *newpcb, err_t err); |
nandgate | 0:6dee052a3fa4 | 34 | friend NetServer; |
nandgate | 0:6dee052a3fa4 | 35 | friend TCPConnection; |
nandgate | 0:6dee052a3fa4 | 36 | |
nandgate | 0:6dee052a3fa4 | 37 | }; |
nandgate | 0:6dee052a3fa4 | 38 | |
nandgate | 0:6dee052a3fa4 | 39 | }; |
nandgate | 0:6dee052a3fa4 | 40 | |
nandgate | 0:6dee052a3fa4 | 41 | #endif /* TCPLISTENER_H */ |