kolban wrote:Have a look at the following:
https://linux.die.net/man/2/sendto
If we look down to return values it states:
On success, these calls return the number of characters sent. On error, -1 is returned, and errno is set appropriately.
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.
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");
}
I knows the return value of sendto indicate and errno indicates.What I said "errno==-1" is based on the return value of sendto is -1.So my question is:What "errno==-1" indicates based on sendto fails.
Sorry for my bad English,and my bad expression and the bad ability of expression.