Sendto fail.errno is -1.What "errno==-1" indicates?Every macro of errno is positive number.
Sendto fail.errno is -1.What "errno==-1" indicates?Every macro of errno is positive number.
Data transmission through wifi,using UDP,call sendto API.errno is -1.What "errno==-1" indicates?From errno.h,every macro of errno is positive number.
Re: Sendto fail.errno is -1.What "errno==-1" indicates?Every macro of errno is positive number.
Have a look at the following:
https://linux.die.net/man/2/sendto
If we look down to return values it states:
https://linux.die.net/man/2/sendto
If we look down to return values it states:
This means that sendto() returns the number of characters sent and not "errno". The "errno" is a C global variable. Commonly the return code from a C function returns a success/error indication and the underlying error can be found as the current value of errno global.On success, these calls return the number of characters sent. On error, -1 is returned, and errno is set appropriately.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: Sendto fail.errno is -1.What "errno==-1" indicates?Every macro of errno is positive number.
kolban wrote:Have a look at the following:
https://linux.die.net/man/2/sendto
If we look down to return values it states:
This means that sendto() returns the number of characters sent and not "errno". The "errno" is a C global variable. Commonly the return code from a C function returns a success/error indication and the underlying error can be found as the current value of errno global.On success, these calls return the number of characters sent. On error, -1 is returned, and errno is set appropriately.
Code: Select all
ret=sendto(sock,start,SEND_START_LEN,0,(struct sockaddr *)&toAddr,sizeof(toAddr))
if(ret<0)
{
printf("errno is %d\n",errno);
}
else
{
printf("send success\n");
}
Sorry for my bad English,and my bad expression and the bad ability of expression.
Who is online
Users browsing this forum: ESP_ondrej, MicroController, Mustafa_ME and 123 guests