Skip to content

socket_sigio test uses shared equeue and thread #5527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions TESTS/netsocket/socket_sigio/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ bool find_substring(const char *first, const char *last, const char *s_first, co
}

void get_data(TCPSocket* sock){
sock->sigio(NULL);
bool result = false;
// Server will respond with HTTP GET's success code
const int ret = sock->recv(buffer, sizeof(buffer) - 1);
Expand Down Expand Up @@ -103,11 +104,7 @@ void prep_buffer() {
}

void test_socket_attach() {
// Dispatch event queue
Thread eventThread;
EventQueue queue(4*EVENTS_EVENT_SIZE);
eventThread.start(callback(&queue, &EventQueue::dispatch_forever));

EventQueue *queue = mbed_event_queue();
printf("TCP client IP Address is %s\r\n", net->get_ip_address());

TCPSocket sock(net);
Expand All @@ -117,7 +114,7 @@ void test_socket_attach() {

prep_buffer();
// Attach a sigio function that adds function to event queue
sock.sigio(queue.event(get_data, &sock));
sock.sigio(queue->event(get_data, &sock));
// Send GET command
sock.send(buffer, strlen(buffer));
// wait for recv data
Expand All @@ -137,11 +134,7 @@ void cb_pass() {
}

void test_socket_detach() {
// Dispatch event queue
Thread eventThread;
EventQueue queue(4*EVENTS_EVENT_SIZE);
eventThread.start(callback(&queue, &EventQueue::dispatch_forever));

EventQueue *queue = mbed_event_queue();
printf("TCP client IP Address is %s\r\n", net->get_ip_address());

TCPSocket sock(net);
Expand All @@ -151,7 +144,7 @@ void test_socket_detach() {

prep_buffer();
// Attach a sigio function that adds function to event queue
sock.sigio(queue.event(cb_fail));
sock.sigio(queue->event(cb_fail));
// Detach function
sock.sigio(NULL);
// Send GET command
Expand All @@ -164,11 +157,7 @@ void test_socket_detach() {
}

void test_socket_reattach() {
// Dispatch event queue
Thread eventThread;
EventQueue queue(4*EVENTS_EVENT_SIZE);
eventThread.start(callback(&queue, &EventQueue::dispatch_forever));

EventQueue *queue = mbed_event_queue();
printf("TCP client IP Address is %s\r\n", net->get_ip_address());

TCPSocket sock(net);
Expand All @@ -178,9 +167,9 @@ void test_socket_reattach() {

prep_buffer();
// Attach a sigio function that adds function to event queue
sock.sigio(queue.event(cb_fail));
sock.sigio(queue->event(cb_fail));
// Override previous attach
sock.sigio(queue.event(cb_pass));
sock.sigio(queue->event(cb_pass));
// Send GET command
sock.send(buffer, strlen(buffer));
recvd.wait();
Expand Down