cancel
Showing results for 
Search instead for 
Did you mean: 

errno

 
Highlighted
Occasional Visitor

errno

Hello,

I need to make a lib with pthread, when I run my make file all is good. But when I run my test program, I test errno in the begining and is already set to 251. Is it normal ??? What can I modify in my Makefile to have errno set to 0 ???

Thanks

$make
gcc -D_REENTRANT -shared -fpic -lpthread gas_configuration.c gas_acquisition.c -o libgas_fifos.sl
gcc -L. -lgas_fifos testComm.c -o test
$./test
Begin
errno : 251
$
5 REPLIES 5
Highlighted
Honored Contributor

Re: errno

You test program is stating a message as
grep 251 sys/errno.h
#define ENOSYS 251 /* Function not implemented */

To make string error output then use

#include

printf ("%s",strerror(errno));

Makefile is not having any problem now. The c program contains the problem now.

Regards
Muthu
Easy to suggest when don't know about the problem!
Highlighted
Occasional Visitor

Re: errno

I need to test errno to know if my recvfrom return EAGAIN.

Code :

retour = recvfrom(t_sockets[indice].socket, payload, FRAME_LENGTH, O_NONBLOCK, &t_sockets[indice].sin_remote, &size_addr);
if(retour >= 0)
{
.......
}
else
{
printf("errno %d\n", errno);
if(errno != EAGAIN)
{
perror("Error in recvfrom");
}
}

Result :
251
Error in recvfrom: Resource temporarily unavailable

How can I correct the problem ??

Thanks for your help.
Highlighted
Honored Contributor

Re: errno

Your are getting EAGAIN because of Non-blocking I/O is enabled using O_NONBLOCK
flag with fcntl() and the receive operation
would block, or the socket has an error that
was set asynchronously.An asynchronous
error can be caused by a gateway failing to
forward a datagram because the datagram
exceeds the MTU of the next-hop network and
the "Don't Fragment" (DF) bit in the datagram
is set.(See SO_PMTU in getsockopt(2).)

To overcome this use setsockopt with SO_PMTU to overcome this problem.

SO_PMTU will not be in mage page so use here,
http://dune.mcs.kent.edu/cgi-bin/man2html?getsockopt(2)

int s_flag=1
setsockopt(s,SO_PMTU,s_flag,sizeof(int));

and check your program now.

Easy to suggest when don't know about the problem!
Highlighted
Occasional Visitor

Re: errno

I have resolved my problem. I use Multi-threaded and I have gorget the option with gcc :
-D_REENTRANT

Thankes for your help
Highlighted
Honored Contributor

Re: errno

And the reason for getting problem and not getting because of -D_REENTRANT is given over at,

http://devrsrc1.external.hp.com/STK/impacts/i321.html

Muthu.
Easy to suggest when don't know about the problem!