This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
socket system call returns file descriptor 0
- To: gcc-help at gcc dot gnu dot org
- Subject: socket system call returns file descriptor 0
- From: "Arun Saini , Gurgaon" <arun at ggn dot hcltech dot com>
- Date: Fri, 6 Jul 2001 01:51:44 +0530
- Cc: gcc at gcc dot gnu dot org
hi all,
I am using red hat linux 7 and gcc 3.0 for an application that needs to use
sockets. On the client end when I use socket(AF_INET, SOCK_STREAM, 0) it
returns descriptor 0 (zero) which is strange as 0 belongs to stdin. If I try
to send data to this socket that also returns 0. A call to 'connect' returns
EINPROGRESS if used in non-blocking mode and SUCCESS if used in blocking
mode. A call to 'select' blocks indefinitely if I give the last parameter as
none which means no data is sent from the server as well (It didn't receive
any data from the previous send call ??? I cannot verify this as the server
is on a chip). I also need to mention that the call to 'socket' is a part of
a C++ shared library that I am using from my application. The library was
also built by me.
Surprisingly if I write a small application to do the same, it behaves
correctly and the call top socket returns 3 and communicates with the server
perfectly well as long as I do not use select which again blocks
indefinitely even though there is data available to be read (I verified this
by directly issuing a call to 'recv').
Any ideas why this could be happening???
Arun Saini