|   | ![[ Previous ]](navbprev.gif)  ![[ Contents ]](navbhome.gif)  ![[ Index ]](navbhelp.gif)  ![[ Next ]](navbnext.gif)  | 
    int Ns_ConnWrite(
    Ns_Conn *conn,
    void *buf,
    int len
    );
The Ns_ConnWrite function attempts to write out the specified length of data from the given buffer to the client. It returns the number of bytes sent or -1 if there is an error. This function may write fewer than len bytes.
    
    /* Write towrite bytes from buf. */
    
    while (towrite > 0) {
    	int nwrote;
    
    	nwrote = Ns_ConnWrite(conn, buf, towrite);
    	if (nwrote == -1) {
    		/* ... handle error ... */
    	}
    	buf += nwrote;
    	towrite -= nwrote;
    }