diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1996-12-25 10:37:09 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1996-12-25 10:37:09 +0000 |
commit | 481f2fe7871aca3171165913d603fc9ce8d12739 (patch) | |
tree | 113e6e1442a19763e655729d3160f27df8f575e0 /socket.c | |
parent | f098021f7c4b021fde38bc91884e467ac9cde676 (diff) | |
download | fetchmail-481f2fe7871aca3171165913d603fc9ce8d12739.tar.gz fetchmail-481f2fe7871aca3171165913d603fc9ce8d12739.tar.bz2 fetchmail-481f2fe7871aca3171165913d603fc9ce8d12739.zip |
Include test code.
svn path=/trunk/; revision=690
Diffstat (limited to 'socket.c')
-rw-r--r-- | socket.c | 34 |
1 files changed, 21 insertions, 13 deletions
@@ -34,6 +34,12 @@ #endif #endif +/* + * There are, in effect, two different implementations here. One + * uses read(2) and write(2) directly with no buffering, the other + * uses stdio with line buffering (for better throughput). Both + * are known to work under Linux. + */ /* #define USE_STDIO */ #ifdef USE_STDIO @@ -116,19 +122,6 @@ va_dcl { } #ifndef USE_STDIO -/* - * FIXME: This needs to be recoded to use stdio, if that's possible. - * - * If you think these functions are too slow and inefficient, you're - * absolutely right. I wish I could figure out what to do about it. - * The ancestral popclient used static buffering here to cut down on the - * number of read(2) calls, but we can't do that because we can have - * two or more sockets open at a time. - * - * The right thing to do would be to use stdio for internal per-socket - * buffering here (which is why SockOpen() returns a file pointer) but - * this causes mysterious lossage. - */ int SockWrite(char *buf, int size, int len, FILE *sockfp) { @@ -164,6 +157,7 @@ char *SockGets(char *buf, int len, FILE *sockfp) *cp = 0; return buf; } + #else int SockWrite(char *buf, int size, int len, FILE *sockfp) @@ -178,4 +172,18 @@ char *SockGets(char *buf, int len, FILE *sockfp) #endif +#ifdef MAIN +/* + * Use the chargen service to test buffering directly. + */ +main() +{ + FILE *fp = SockOpen("localhost", 19); + char buf[80]; + + while (SockGets(buf, sizeof(buf)-1, fp)) + SockWrite(buf, 1, strlen(buf), stdout); +} +#endif /* MAIN */ + /* socket.c ends here */ |