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
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