cancel
Showing results for 
Search instead for 
Did you mean: 

can't create RAW SOCKET FeeRTOS+LWIP

TAlex.11
Associate

I'm trying to create a project on the Nucleo-STM32H743ZI, in which I want to implement the ICMP protocol on remote hosts. I took the example of LWIP contrib-2.0.1. The problem is that when creating a RAW SOCKET, it always returns -1.

 socket = lwip_socket (AF_INET, SOCK_RAW, IPPROTO_ICMP);

In this case, if you create a SOCK_DGRAM or SOCK_STREAM, then everything is successfully created.

What am I doing wrong?

5 REPLIES 5
Hoang_Tran
Associate III

I have a similar situation!

Ivan Pletnev
Associate II

I have a same problem. TAlex.1, did you find some solution?

Alex.Ag.
Associate II

You need to rebuild LWIP with LWIP_RAW defined in lwipopts.h in order to include RAW socket support. It seems it is not defined by default.

Regards,

Alexander

LWIP_RAW is defined in my code. It's looks like thread freezing, diagnostic messages and Socket Debug messages are not displaying in this case. Howewer, if type of socket are SOCK_DGRAM or SOCK_STREAM, everything is OK

if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) {
		puts("PING socket error");
		return;
	}
	printf("Socket No %u created\r\n", s);

Piranha
Chief II

You can't expect higher layers and APIs (especially thread-safe ones) to work, while lower layers are flawed and blatantly violating multithreading and other requirements.

https://community.st.com/s/question/0D50X0000BOtfhnSQB/how-to-make-ethernet-and-lwip-working-on-stm32