This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: socket system call returns file descriptor 0
- To: "Arun Saini , Gurgaon" <arun at ggn dot hcltech dot com>
- Subject: Re: socket system call returns file descriptor 0
- From: Ingo Krabbe <ikrabbe at earthling dot net>
- Date: Fri, 6 Jul 2001 20:03:09 +0200 (CEST)
- cc: <gcc-help at gcc dot gnu dot org>, <gcc at gcc dot gnu dot org>
- Reply-To: Ingo Krabbe <i dot krabbe at dokom dot net>
On Fri, 6 Jul 2001, Arun Saini , Gurgaon wrote:
> 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. [ ... ] 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').
>
I must admit, this is a very strange error. Your diagnostics are a
bit sparse though. It may help if you can give a short part of the
surrounding c++ from your library and your application which calls it. It
may help you even more to experiment with this error and look what happens
in different situations and formulations. There may be an error in your
library, but it sounds more like an error you do somewhere.
CU INGO