Unable to stablish any tcp socket

Hi again, I0m very slowly progressing. Till now I’ve been able to establish my wifi connection and get an IP, but there is no way to establish any connection.

I keep getting “Connect failed -1!!”

Here is my code, any clue???

#include “FreeRTOS.h”
#include “lwip_netconf.h”
#include “lwip/api.h”

#include “MQTTClient/MQTTClient.h”
#include “MQTTClient/MQTTFreertos.h”

#include “wifi_conf.h”

#define usTaskStackSize 1024
#define MQTT_DEBUG 1
#define LWIP_DNS 1
#define LWIP_TCP 1
#define THREAD_STACK_SIZE 1024
#define MQTT_SELECT_TIMEOUT 1
//#define PBUF_POOL_SIZE 60
extern struct netif xnetif;

static void messageArrived(MessageData* data)
{
DiagPrintf(“Message arrived on topic %s: %s\n”, data->topicName->lenstring.data, (char *)data->message->payload);
}

void init()
{
int rc;
Network network;
ip_addr_t dns_server;
char* address = “192.168.1.199”;

DiagPrintf(“Task started\n”);

wifi_on(RTW_MODE_STA); // Inicia el modo STA

rc=wifi_connect(““,RTW_SECURITY_WPA_TKIP_PSK,””,6,8,-1,NULL);
if (rc == RTW_SUCCESS)
DiagPrintf(“Connected to Wifi \n”);
else
DiagPrintf(“Not connected %d\n”,rc);

DiagPrintf( “Start LwIP\n”);
LwIP_Init();

DiagPrintf(“\nIP address: %s\n”, ip4addr_ntoa(netif_ip4_addr(&xnetif)));
DiagPrintf(“IP GW: %s\n”, ip4addr_ntoa(netif_ip4_gw(&xnetif)));

DiagPrintf( “Start DHCP\n”);
LwIP_DHCP(0, DHCP_START);

DiagPrintf(“\nIP address: %s\n”, ip4addr_ntoa(netif_ip4_addr(&xnetif)));
DiagPrintf(“IP GW: %s\n”, ip4addr_ntoa(netif_ip4_gw(&xnetif)));

while(wifi_is_ready_to_transceive(RTW_STA_INTERFACE) != RTW_SUCCESS)
{
DiagPrintf( “Waiting for Wi-Fi.\n”);
vTaskDelay(5000 / portTICK_PERIOD_MS);
}

DiagPrintf( “Start DNS\n”);
dns_init();

if (rc=dns_getserver(0, &dns_server) == 0) {
    DiagPrintf("DNS Server: %s\n", ip4addr_ntoa(&dns_server));
} else {
    DiagPrintf("No se pudo obtener el servidor DNS (puede que no esté configurado)\n");
}

DiagPrintf(“Network Init\n”);
NetworkInit(&network);

DiagPrintf( “Connect Network "%s"\n”, address);
while ((rc = NetworkConnect(&network, address, 80)) != 0){
DiagPrintf( “Return code from network connect is %d\n”, rc);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}

DiagPrintf( “"%s" Connected\n”, address);
}

int main(void)
{
int rc;
DiagPrintf(“Main started\n”);
rc=xTaskCreate(init, ((const char*)“init”), usTaskStackSize + 128, NULL, tskIDLE_PRIORITY + 3 + PRIORITIE_OFFSET, NULL);
vTaskStartScheduler();
DiagPrintf(“Scheduler Ended\n”);
}

Can anyone give a clue??

Any proffesional developer wishing to help us (paid) to finish this port??

Thx