|
Blue Forest http://www.lslnet.com at 2:08 p.m. on August 16, 2006
|
|
Gcc 3.2 does not support ifstream (int fh) how do?
|
|
Just upgraded to redhat 9, passed the following code compiler.
......
Int iSock; ISock = socket (AF_INET, SOCK_STREAM, 0); SSoin.sin_family = AF_INET; SSoin.sin_addr.s_addr = inet_addr (strHostAdd); SSoin.sin_port = htons (atoi (strPort));
Ierror = connect (iSock, (struct sockaddr *) &sSoin, sizeof (sSoin));
......
Ifstream ifSock (iSock); -------------------------------------
Documents just to find out that C + + does not support the new standards above this.
How do?
|
|
|
Nobody knows?
|
|
Nobody knows?
|
|
|
Partial solution to the problem
|
|
......
Using namespace std; #include "Ext/stdio_filebuf.h> ......
Typedef __gnu_cxx : : stdio_filebuf<char> FILEBUF; ......
Int ierror;
Sock = socket (AF_INET, SOCK_STREAM, 0); Soin.sin_family = AF_INET; Soin.sin_addr.s_addr = inet_addr (strAdd); Soin.sin_port = htons (atoi (strPort));
Ierror = connect (sock, (struct sockaddr *) &soin, sizeof (soin));
FILEBUF ifb (sock, ios_base : : in, false, 1); This is in doubt?
Std : : istream ifsock (&ifb);
But GCC website : Synopsis : //gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/class____gnu__cxx_1_1stdio__filebuf.html#____gnu__cxx_1_1stdio__filebufa0
Note : Template<typename CharT, typename Traits> __gnu_cxx : : Stdio_filebuf< CharT, Traits ": : stdio_filebuf (int __fd. Openmode __mode ios_base : : : : Std. Bool __del. Size_t size = static_cast< size_t "(BUFSIZ) )
Parameters : An open file descriptor fd. Same meaning as in a standard mode filebuf. Whether to close the file on del destruction. Optimal or preferred size of internal buffer size, in bytes. Note that it includes a position ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ For the overflow char, therefore, can 't be smaller ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Than 2. ^^^^^^^
This constructor associates a file stream buffer with an open POSIX file descriptor. Iff del is true. then the associated file will be closed when the stdio_filebuf is closed/destroyed.
But when I size>1 procedures will be problems, and this procedure can imitate browsers x communications, size "1, ifsock.read (chBuf, iLength); Reading data from the server to respond, To "KeepAliveTimeout" x persistent connections overtime before returning. I think it is not __gnu_cxx : : stdio_filebuf within the buffer is full, and data Has been completed. Put the size as the one that FILEBUF ifb (sock, ios_base : : in, false, 1). So far found no procedural problems arise.
However, I do not rest assured that I will write you have any questions.
|
|
|
Re : partial solution to the problem
|
|
I long to answer such a question, and I made room in my previous articles?
|
|
|
Re : partial solution to the problem
|
|
Thank you find.
Synopsis : //www.lslnet.com/linux/showthreaded.php?Cat=&Board=program&Number=415339&Search=true&Forum=All_Forums&Words=Using%20FILE%2As%20and%20file%20descriptors%20with%20IOStreams&Match=Entire%20Phrase&Searchpage=0&Limit=25&Old=allposts&Main=415339] Synopsis : //www.lslnet.com/linux/showthreaded.php?Cat=&Board=program&Number=415339&Search=true&Forum=All_Forums&Words=Using%20FILE%2As%20and%20file%20descriptors%20with%20IOStreams&Match=Entire%20Phrase&Searchpage=0&Limit=25&Old=allposts&Main=415339
But still do not understand why : Template<typename CharT, typename Traits> __gnu_cxx : : Stdio_filebuf< CharT, Traits ": : stdio_filebuf (int __fd. Openmode __mode ios_base : : : : Std. Bool __del. Size_t size = static_cast< size_t "(BUFSIZ) )
Parameters : An open file descriptor fd. Same meaning as in a standard mode filebuf. Whether to close the file on del destruction. Optimal or preferred size of internal buffer size, in bytes. Note that it includes a position for the overflow char, therefore, can 't be smaller than 2. Size not smaller than 2. ^^^^^^^^^^^^^^^^^^^^^^^^
This constructor associates a file stream buffer with an open POSIX file descriptor. Iff del is true. then the associated file will be closed when the stdio_filebuf is closed/destroyed.
But when I size>1 procedures will be problems, and this procedure can imitate browsers x communications, size "1, ifsock.read (chBuf, iLength); Reading data from the server to respond, To "KeepAliveTimeout" x persistent connections overtime before returning. I think it is not __gnu_cxx : : stdio_filebuf within the buffer is full, and data Has been completed. Put the size as the one that FILEBUF ifb (sock, ios_base : : in, false, 1). So far found no procedural problems arise.
However, I do not rest assured that I will write you have any questions.
|
|
|
Will the guidance of experts.
|
|
To address the above questions, which I am looking at gcc.gnu.org libstdc++ part of the description and source code, but I am limited, See very slow. On the above issues, please master guiding.
|
|