socket system call returns file descriptor 0

Ingo Krabbe ikrabbe@earthling.net
Fri Jul 6 10:58:00 GMT 2001


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



More information about the Gcc-help mailing list