This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

socket system call returns file descriptor 0


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]