Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 3 months ago.
Socket Blocking = False not working on K64F?
Does the set_blocking(false,xxx) work for the K64F?
When running this on the K64F the output stops indefinitely at "Wait for new connection" when it appears that it should continue on after 1.5s. I only have the K64F to test with at the moment so not sure if I'm missing something or if the library is different for the K64F
Example - from https://developer.mbed.org/handbook/Socket
include the mbed library with this snippet
printf("\nWait for new connection...\n"); TCPSocketConnection client; server.accept(client); client.set_blocking(false, 1500); // Timeout after (1.5)s printf("Connection from: %s\n", client.get_address());
Question relating to:
1 Answer
9 years, 2 months ago.
i'm discovering similar issues, but my code runs fine till I wan't to read out data.
TCPSocketConnection client; server.accept(client); client.set_blocking(false, 200); // Timeout after (200)ms int i = 0; while (true) { printf("goin' to read - %i\r\n", i++); int n = client.receive(buffer, sizeof(buffer)); }
That's just a short overview. The loop reads some data, but then it reads no more data. After some more loops the connection is refused. If I use blocking it works much better. But I don't want to use it blocking. Is there some method like client.available() as I had it on the Arduino to see wheter I can read data right now or not?
A clarification on this - the client.set_blocking(false, 1500) is working just fine - but is there a way to have the server.accept not block?
posted by Jeffrey Alexander 03 Aug 2015