This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem connecting bsd (tcp) socket with ethernet

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