Hi there,
I'm trying to use the shared event queue for socket events as detailed in the example: https://os.mbed.com/docs/mbed-os/v5.11/apis/network-socket.html
I have a class that takes data from a TCPSocket and processes it. So I have a server socket that presents client connections to my class for sending/receiving data.
In main() I have a TCPSocket that I call open, bind and then listen and I pass a method of my class as the event handler.
EventQueue *queue = mbed_event_queue();
Event<void()> handler = queue->event(&DaliMaster, &Dali::server_sigio, &socket);
socket.set_blocking(false);
socket.sigio(handler);
handler();
What I want to do is have my class handle the socket->accept() and create a new event handler for the client connection. So I have the following code after I've got a new socket from accept():
Class::method() {
Event<void()> client_handler = queue->event(this, &Dali::client_sigio, client);
client->set_blocking(false);
client->sigio(client_handler);
client_handler();
}
What I'm getting is a runtime exception in Event.h on line 158 which is an assert to check "id". It fires when I call client_handler() the first time so perhaps I can't set up the event like I've done?
In the second call, client is a pointer to a TCPSocket.
Any ideas what I'm doing wrong?
Hi there,
I'm trying to use the shared event queue for socket events as detailed in the example: https://os.mbed.com/docs/mbed-os/v5.11/apis/network-socket.html
I have a class that takes data from a TCPSocket and processes it. So I have a server socket that presents client connections to my class for sending/receiving data.
In main() I have a TCPSocket that I call open, bind and then listen and I pass a method of my class as the event handler.
What I want to do is have my class handle the socket->accept() and create a new event handler for the client connection. So I have the following code after I've got a new socket from accept():
What I'm getting is a runtime exception in Event.h on line 158 which is an assert to check "id". It fires when I call client_handler() the first time so perhaps I can't set up the event like I've done?
In the second call, client is a pointer to a TCPSocket.
Any ideas what I'm doing wrong?