cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H743ZI : I can not do a TCP/IP Socket communication

eymarf
Associate II

Hello,

I try to do a connection via TCP with LWIP/FreeRTOS activated (ioc file joined)

For testing i use telnet command and I am unable tio pass the "accept" function.

Here the simple piece of code:

int sock, newconn, size;

struct sockaddr_in address, remotehost;

/* create a TCP socket */

if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)

{

trace("Socket : Echec");

return;

}

trace("Socket : Ok");

/* bind to port 80 at any interface */

address.sin_family = AF_INET;

address.sin_port = htons(80);

address.sin_addr.s_addr = INADDR_ANY;

if (bind(sock, (struct sockaddr *)&address, sizeof (address)) < 0)

{

trace("Bind : Echec");

return;

}

trace("Bind : Ok");

/* listen for incoming connections (TCP listen backlog = 5) */

listen(sock, 5);

size = sizeof(remotehost);

while (1)

{

trace("Connection : Waiting");

newconn = accept(sock, (struct sockaddr *)&remotehost, (socklen_t *)&size);

trace("Connection : Accepted");

}

A big thanks in advance if somehow see what that's wrong.

0 REPLIES 0