We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
I am actually trying (with a MCBSTM32F400 KEIL) to create a tcp socket and connect it with the ethernet.
Here is my code:
int socket; SOCKADDR_IN addr; conn_keil->socket = socket(AF_INET,SOCK_STREAM, 0); addr.sin_family = AF_INET; addr.sin_addr.s_b1 = 127; addr.sin_addr.s_b2 = 0; addr.sin_addr.s_b3 = 0; addr.sin_addr.s_b4 = 1; addr.sin_port = htons(1883); connect(conn_keil->socket,(SOCKADDR *)&addr, sizeof(addr));
Unfortunately, the connect() function is blocking and I can't get out of it while launching my application or just debugging it. I looked on the internet and found at http://www.keil.com/support/man/docs/rlarm/rlarm_connect.htm that the connect function could be in blocking mode. I don't understand why it stays stuck and how to get out of it to continue my program.
All of this is needed to make a mqtt communication with a local server (hosted at 127.0.0.1) listening at port 1883.
I know I am not clear enough but if you have some clues to solve my problem I would be totally happy.
Thank you in advance,
Alexandre
IP address 127.0.0.1 is a loopback IP address. The address is used to establish an IP connection to the same device.It is theoretically possible to connect to this "localhost" address, but you must also add a server application and load both server + client into your MCBSTM32F400. In other words, you need to add an MQTT server to the application.Because this is probably not what you want, you need to use a different IP address to connect to. The real address of the MQTT server, not an address of type 127.x.x.x