This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: about read(...) of TCP/IP
- To: <Fano dot Ramparany at rd dot francetelecom dot fr>
- Subject: Re: [ECOS] about read(...) of TCP/IP
- From: "ylyuan" <ylyuan at davform dot com>
- Date: Fri, 30 Mar 2001 10:27:39 +0800
- Cc: "ecos-discuss" <ecos-discuss at sourceware dot cygnus dot com>
- References: <3AC20BFF.EFFAAB7@rd.francetelecom.fr>
I think the third parameter of read() is the size (in bytes) of buffer(second parameter),and
the return is the actual size it read. I may use the return of read to judge what to do next,
but I couldn't expect the accurate bytes the other end of the socket sends .Th program
runs right under linux.
Thanks a lot!
> Have a look at the sizeof manual page. It returns the size (in bytes) of
> a type
> (ex. sizeof (char) returns 1). What you should give "read" is the number
> of
> bytes you expect the other end of the socket to send. If it sends less
> bytes,
> my guess is that you will wait forever.
>
> Fano
>
> >Subject: about read(...) of TCP/IP
> >Date: Wed, 28 Mar 2001 09:42:46 +0800
> >From: "ylyuan" <ylyuan@davform.com>
> >To: "ecos-discuss" <ecos-discuss@sourceware.cygnus.com>
> >
> >Hi,part of my program is:
> > if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
> > printf("error to creat a socket\n");
> > exit(1);
> > }
> > if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
> > printf("error to connect\n");
> > exit(1);
> > }
> > read(s,buf,sizeof(buf));
>
> Because the destination connected is a pop3 server,the function of read
> should gain some information ,but it won't
> return.From the buffer of hardware,I can see the information that I
> want.Because the test of ppp_ping.c runs right,so I doubt
> the question exists in TCP.
> Thanks a lot!