LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   connect fails, errno is 0 however (https://www.linuxquestions.org/questions/linux-kernel-70/connect-fails-errno-is-0-however-4175558262/)

tilman1 11-07-2015 01:48 PM

connect fails, errno is 0 however
 
Dear all

though not strictly a kernel problem, I would think that this is the most suitable group. If not, please let me know, and I will post it to a different group.

I am debugging a c++ program on an embedded arm system (linux kernel 3.17.4) that is showing a funny behaviour.

In a method, a network socket is opened as non-blocking and then connected to a server. On the server side, I can see that the connection request is always successful. On the client side, the connect routine however sometimes returns with -1, while the error code (errno) is 0.

Within the program (daemon), the behaviour is reproducible,i.e. depending on the context from which the method running the connect routine is called, connect returns -1 or 0. I can however not isolate it, i.e. write a small program that reproduces the behaviour.

Any thoughts on that ? Maybe a race condition ? Is connect/errno reentrandant-safe?


Thanks
Tilman

but I cannot isolate it. (write a small program that always shows it). It could be dependent on the caller.

The program is written in C++ (not sure if it


fcntl(fd, F_SETFL, O_NONBLOCK)
result = ::connect(fd, (struct sockaddr *)&saddr, sizeof(saddr));

tilman1 11-07-2015 03:01 PM

Hello all

apparently, errno is reentrant-safe -- at least this is what the man page says.

Regards

Tilman


All times are GMT -5. The time now is 03:04 AM.