Connexion STM32 - localhost

Good morning everyone !

I am a french student and I am working with a STM32L475 on a project. The purpose of the project is to connect the STM32 to the Wifi, then to connect the device to a server and then to do SQL requests between the server and the device.

For this, I created a new program, using the template “Wifi example for Mbed OS” and the Wifi Conecction works well ! Today, I’am trying to connect my STM32 to the server, opening a socket, and using the function “socket.connect()”. For the moment, I am trying with a localhost. In my code I have the following lines :

reponse = socket.connect(“localhost/”, 80);
if (reponse != 0) {
printf(“Erreur Connecting\n”);
}
printf(“Connected to the serveur\n”);

And unfortunately, I never have “Connected to the serveur” message…

If someone can help me :slight_smile !

Hello,

just start with check what that method return - Errors table line 82

BR, Jan

Ok thanks a lot ! I have the error -3009 : “DNS failed to complete successfully”

I am not so experienced with this problematic but from my point of view the “localhost” is the Nucleo board itself. And because your board not provide a server, it will fail.

What is Localhost? Localhost Explained for Beginners (hostinger.com)
i cannot connect localhost use ethernet web client (arduino.cc)

BR, Jan

Ok, in fact I wanted to connect the Nucleo to a server which is on my laptop (ie “localhost”)…