Cachemgr code: Why write to stdout?

From: Kate Patterson <kate@dont-contact.us>
Date: Fri, 14 Mar 1997 10:05:45 +0000

This is probably blindingly obvious, it's caught me out twice and I'd
like to understand it:

I'm examining the cachemgr.c code and when sending a request to the
cache for information a socket is opened on "conn":

    /* Connect to the server */
    if ((conn = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
        perror("client: socket");
        exit(1);
    }
    if ((conn = (conn, hostname, portnum)) < 0) {
        printf("Error: connecting to cache mgr: %s:%d\n",
hostname, portnum);
        printf("%s</PRE></BODY></HTML>\n", xstrerror());
        exit(1);
    }
    bytesWritten = write(conn, msg, strlen(msg));

and then once the connection is made, the value of "conn" is overwritten
by the return value of client_comm_connect() - 1 if successful.

Why is this? Is it something to do with how the browser sends requests?
I don't understand why the message is written to STDOUT - or is it that
once a connection is made, STDOUT is re-directed to this connection? If
that is the case how does printf continue to write to the screen?

Thanks

Kate
Received on Fri Mar 14 1997 - 02:29:09 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:34:41 MST