Wi-Fi connection timeout?

Hello everybody,

I’m connecting to some TCP servers using my new LinkIt ONE and the LWiFiClient class.

The .connect() method returns 1 if it connects to the IP address I specified, but if the IP address doesn’t exists or doesn’t accept connections (for example, if the server is down) it doesn’t return anything and the code gets stuck there. I assume it should timeout then return 0 as per the documentation.


int conn = c.connect("", 8080);
if(conn == 1){
} else {

If is down, c.connect doesn’t return anything and I can’t get into the else branch.

Any ideas on how to solve this?

Thank you

Update: It looks like it’s working and it was only my fault. I had a boolean variable named “connected” that conflicted with the LWifiClient which also has a .connected() function.

Everything is working fine now.

nice~ :smiley:

I have problems trying to do the opposite now: I want the LinkIt to be a TCP server and receive commands from clients.

This is my code, based on the mediatek documentation (sadly there are no working examples), but I can’t understand why it doesn’t work.

It connects to the Wi-Fi just fine, yet it refuses all the connections by the clients.

[code]#include <LWiFi.h>
#include <LWiFiClient.h>
#include <LWiFiServer.h>

#define AP_NAME “TP-LINK”
#define PASSWORD “mypassword”
#define PORT 8080

boolean first = true;

LWiFiClient c;
LWiFiServer server(8080);

void setup() {
Serial.println(“Connected to Wi-Fi!”);

void loop() {
c = server.available();
first = false;
char ch = c.read();

Any ideas on how to make this work? Thank you