I think that you misunderstood the data flow a bit. So you have ... address.sin_family = AF_INET; address.sin_addr.s_addr = INADDR_ANY; address.sin_port = htons(PORT);
if (bind(server_fd, (struct sockaddr *)&address, sizeof(address)) < 0) { perror("bind failed"); exit(EXIT_FAILURE); } ... printf("waiting for requests at %s:%d...\n", inet_ntoa(address.sin_addr), PORT); So you assign INADDR_ANY to a address.sin_addr.s_addrand then call "int bind(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen);" that has "const" modifier for "addr" parameter hoping that it will modify the value that you just assigned. That just simply will not work. чт, 21 вер. 2023 р. о 15:22 Gustavo Soares <gustavo.felipesoa...@hotmail.com> пише: > I've attached a simpler version of the server file removing the logic for > the incoming requests so you can take a better look. How should I make the > API call to get the device IP? > ------------------------------ > *De:* Petro Karashchenko <petro.karashche...@gmail.com> > *Enviado:* quinta-feira, 21 de setembro de 2023 09:00 > *Para:* dev@nuttx.apache.org <dev@nuttx.apache.org> > *Assunto:* Re: different IP than expected > > Yeah, > > But what is in between > [image: image.png] > and > [image: image.png] > ??? > > Do you have any API call to get the IP? Because I read that like "int a = > 10; printf("%d", a);" > > If there is no API call to update "address" then you simply will print > "INADDR_ANY" value. > > чт, 21 вер. 2023 р. о 14:42 MIGUEL ALEXANDRE WISINTAINER < > tcpipc...@hotmail.com> пише: > > I mean, ifconfig, and capture the ip… > > Enviado do meu iPhone > > Em 21 de set. de 2023, à(s) 08:24, Gustavo Soares < > gustavo.felipesoa...@hotmail.com> escreveu: > > > Hi, Petro! > > I use this struct: > > [image: image.png] > > and this where I use the inet_ntoa: > > [image: image.png] > ------------------------------ > *De:* Petro Karashchenko <petro.karashche...@gmail.com> > *Enviado:* quinta-feira, 21 de setembro de 2023 08:16 > *Para:* dev@nuttx.apache.org <dev@nuttx.apache.org> > *Assunto:* Re: different IP than expected > > Hi, > > But what do you pass to "inet_ntoa"? Maybe you get the IP of your PC or a > default router IP and try to print it? > > Best regards, > Petro > > чт, 21 вер. 2023 р. о 14:06 Gustavo Soares < > gustavo.felipesoa...@hotmail.com> пише: > > I don't know if I can reproduce this in another app, but my question is > why does the server listen to requests in one IP adress (ending with 15) > and when I retrieve its IP it shows a different one? About the ifconfig > command, this is the output: > > > > the server response to the GET request (the request was sent to the > configured IP using ifconfig): > > > the IP address the server returns with the inet_ntoa() method: > > > ------------------------------ > *From:* Petro Karashchenko <petro.karashche...@gmail.com> > *Sent:* Thursday, September 21, 2023 6:59:01 AM > *To:* dev@nuttx.apache.org <dev@nuttx.apache.org> > *Subject:* Re: different IP than expected > > Hi, > > "INADDR_ANY" definitely does not match "listens to the defined IP" > statement. I do not understand exactly what you are trying to do, but it > would be good to know what is the output of "ifconfig" running from NSH. > If you do not want to share code details, maybe you can check how your > application behaves on Linux and compare to what behavior you observe with > NuttX. > Can this somehow be reproduced with one of the apps available in the NuttX > repo? > > Best regards, > Petro > > чт, 21 вер. 2023 р. о 03:09 Gustavo Soares < > gustavo.felipesoa...@hotmail.com> пише: > > Hello everyone! > > I configured NuttX to a certain IP address and I have a webserver which > listens to the defined IP: > > > > > > The HTML file above has a variable that contains the server IP address, > but it is a different one: > > > > the server replaces the text SERVER_IP_ADDRESS to it's actual IP and then > sends the file to the client. This is the method I used to get the IP > address: > > > > Why is it a different IP? The server is listening to one but this method > returns another one. > > >