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
I am experiencing the same issue. For me the the call listed below is blocking (I am also trying to connect to port 1883)
netDNSc_GetHostByNameX(name, addr_type, &addr);
Hi raviiyer06,
I see that GetHostByName is non-blocking, whereas GetHostByName is blocking:
www.keil.com/.../group__starting__dns.html
You could try using the non-blocking function and check the return value, to get an idea of what could be going wrong.
Other general things to check,
- that you have enough resources configured in the RTX config file, all of the Network config file
- Try the steps listed here http://www.keil.com/pack/doc/mw/Network/html/network_troubleshoot.html
- Turn on the event recorder, and look at the log. https://www.keil.com/pack/doc/compiler/EventRecorder/html/er_use.html
To get answers more relevant to you, please tell the Keil community:
- What version of the Keil tools you are using,
- If you are using IPv4 or v6?
- Your DNS settings in the Net_config_ETH0.h
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