This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


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

Re: about fdopen


Why do you want to use fdopen for?
If you want to write into the socket you just have to use the function write.
write(s, <data>, <datalength>)
If you want to read from the socket you just have to use the function read.
read(s,<data>,<datalength>)

Fano


> From: "ylyuan" <ylyuan@davform.com>
> To: "ecos-discuss" <ecos-discuss@sourceware.cygnus.com>
>
> Hi,part of my program is :
>     static FILE *sfp;
>     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);
>     }
>     if ((sfp = fdopen(s, "w")) == 0) {
>         printf("error to fdopen s\n");
>         exit(1);
>     }
>
>     socket() and connect() are right,but fdopen() can't return,who can tell me why?
>     Thanks a lot!


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