A version of LWIP, provided for backwards compatibility.
Dependents: AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more
trunk/Core/TCPListener.cpp@0:5e1631496985, 2012-05-08 (annotated)
- Committer:
- root@mbed.org
- Date:
- Tue May 08 15:32:10 2012 +0100
- Revision:
- 0:5e1631496985
initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
root@mbed.org | 0:5e1631496985 | 1 | #include "TCPListener.h" |
root@mbed.org | 0:5e1631496985 | 2 | #include "NetServer.h" |
root@mbed.org | 0:5e1631496985 | 3 | |
root@mbed.org | 0:5e1631496985 | 4 | using namespace std; |
root@mbed.org | 0:5e1631496985 | 5 | using namespace mbed; |
root@mbed.org | 0:5e1631496985 | 6 | |
root@mbed.org | 0:5e1631496985 | 7 | err_t TCPListener::accept_callback(void *arg, struct tcp_pcb *newpcb, err_t err) { |
root@mbed.org | 0:5e1631496985 | 8 | TCPListener *listener = static_cast<TCPListener *>(arg); |
root@mbed.org | 0:5e1631496985 | 9 | if(listener) { |
root@mbed.org | 0:5e1631496985 | 10 | return (listener->accept)(newpcb, err); |
root@mbed.org | 0:5e1631496985 | 11 | } |
root@mbed.org | 0:5e1631496985 | 12 | return ERR_OK; |
root@mbed.org | 0:5e1631496985 | 13 | } |
root@mbed.org | 0:5e1631496985 | 14 | |
root@mbed.org | 0:5e1631496985 | 15 | void TCPListener::bind() { |
root@mbed.org | 0:5e1631496985 | 16 | NetServer::ready(); |
root@mbed.org | 0:5e1631496985 | 17 | open(); |
root@mbed.org | 0:5e1631496985 | 18 | tcp_arg(this->_pcb, static_cast<void *>(this)); |
root@mbed.org | 0:5e1631496985 | 19 | if(tcp_bind(this->_pcb, IP_ADDR_ANY, this->_port) == ERR_OK) { |
root@mbed.org | 0:5e1631496985 | 20 | this->_pcb = tcp_listen(this->_pcb); |
root@mbed.org | 0:5e1631496985 | 21 | tcp_accept(this->_pcb, TCPListener::accept_callback); |
root@mbed.org | 0:5e1631496985 | 22 | } |
root@mbed.org | 0:5e1631496985 | 23 | } |