Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Core/TCPListener.cpp
- Committer:
- screamer
- Date:
- 2012-11-20
- Revision:
- 1:284f2df30cf9
- Parent:
- 0:7a64fbb4069d
File content as of revision 1:284f2df30cf9:
#include "TCPListener.h"
#include "NetServer.h"
using namespace std;
using namespace mbed;
err_t TCPListener::accept_callback(void *arg, struct tcp_pcb *newpcb, err_t err) {
TCPListener *listener = static_cast<TCPListener *>(arg);
if(listener) {
return (listener->accept)(newpcb, err);
}
return ERR_OK;
}
void TCPListener::bind() {
NetServer::ready();
open();
tcp_arg(this->_pcb, static_cast<void *>(this));
if(tcp_bind(this->_pcb, IP_ADDR_ANY, this->_port) == ERR_OK) {
this->_pcb = tcp_listen(this->_pcb);
tcp_accept(this->_pcb, TCPListener::accept_callback);
}
}