version 1.7 | | version 1.8 |
---|
| | |
| | |
/* | | /* |
* static char *rcsid_sockets_c = | | * static char *rcsid_sockets_c = |
* "$Id: lowlevel.c,v 1.7 2003/09/13 05:02:14 mwedel Exp $"; | | * "$Id: lowlevel.c,v 1.8 2003/12/02 18:51:44 ryo_saeba Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
The author can be reached via e-mail to mark@pyramid.com | | The author can be reached via e-mail to mark@pyramid.com |
*/ | | */ |
| | |
/* newsocket.c contains some base functions that both the client and server | | /** |
| | * \file |
| | * Low-level socket-related functions. |
| | * |
| | * \date 2003-12-02 |
| | * |
| | * Contains some base functions that both the client and server |
* can use. As such, depending what we are being compiled for will | | * can use. As such, depending what we are being compiled for will |
* determine what we can include. the client is designed have | | * determine what we can include. the client is designed have |
* CFCLIENT defined as part of its compile flags. | | * CFCLIENT defined as part of its compile flags. |
| | |
* | | * |
******************************************************************************/ | | ******************************************************************************/ |
| | |
/* this readsfrom fd and puts the data in sl. We return true if we think | | /** |
| | * This reads from fd and puts the data in sl. We return true if we think |
* we have a full packet, 0 if we have a partial packet. The only processing | | * we have a full packet, 0 if we have a partial packet. The only processing |
* we do is remove the intial size value. len (As passed) is the size of the | | * we do is remove the intial size value. len (As passed) is the size of the |
* buffer allocated in the socklist. We make the assumption the buffer is | | * buffer allocated in the socklist. We make the assumption the buffer is |
| | |
* | | * |
******************************************************************************/ | | ******************************************************************************/ |
| | |
/* Adds data to a socket buffer for whatever reason. | | /** |
| | * Adds data to a socket buffer for whatever reason. |
| | * |
* ns is the socket we are adding the data to, buf is the start of the | | * ns is the socket we are adding the data to, buf is the start of the |
* data, and len is the number of bytes to add. | | * data, and len is the number of bytes to add. |
*/ | | */ |
| | |
#endif | | #endif |
} | | } |
| | |
/* When the socket is clear to write, and we have backlogged data, this | | /** |
| | * Writes data to socket. |
| | * |
| | * When the socket is clear to write, and we have backlogged data, this |
* is called to write it out. | | * is called to write it out. |
*/ | | */ |
void write_socket_buffer(NewSocket *ns) | | void write_socket_buffer(NewSocket *ns) |
| | |
} while (ns->outputbuffer.len>0); | | } while (ns->outputbuffer.len>0); |
} | | } |
| | |
/* This writes data to the socket. - It is very low level - | | /** |
| | * This writes data to the socket. - It is very low level - |
* all we try and do is write out the data to the socket | | * all we try and do is write out the data to the socket |
* provided (ns). buf is the data to write, len is the number | | * provided (ns). buf is the data to write, len is the number |
* of bytes to write. IT doesn't return anything - rather, it | | * of bytes to write. IT doesn't return anything - rather, it |
| | |
} | | } |
| | |
| | |
/* Takes a string of data, and writes it out to the socket. A very handy | | /** |
| | * Takes a string of data, and writes it out to the socket. A very handy |
* shortcut function. | | * shortcut function. |
*/ | | */ |
void cs_write_string(NewSocket *ns, const char *buf, int len) | | void cs_write_string(NewSocket *ns, const char *buf, int len) |
| | |
} | | } |
| | |
| | |
/* Send With Handling - calls Write_To_Socket to send data to the client. | | /** |
| | * Calls Write_To_Socket to send data to the client. |
| | * |
* The only difference in this function is that we take a SockList | | * The only difference in this function is that we take a SockList |
*, and we prepend the length information. | | *, and we prepend the length information. |
*/ | | */ |
| | |
Write_To_Socket(ns, msg->buf, msg->len); | | Write_To_Socket(ns, msg->buf, msg->len); |
} | | } |
| | |
/* Takes a string of data, and writes it out to the socket. A very handy | | /** |
| | * Takes a string of data, and writes it out to the socket. A very handy |
* shortcut function. | | * shortcut function. |
*/ | | */ |
void Write_String_To_Socket(NewSocket *ns, char *buf, int len) | | void Write_String_To_Socket(NewSocket *ns, char *buf, int len) |
| | |
*/ | | */ |
CS_Stats cst_tot, cst_lst; | | CS_Stats cst_tot, cst_lst; |
| | |
/* Writes out the gathered stats. We clear cst_lst. | | /** |
| | * Writes out the gathered stats. We clear cst_lst. |
*/ | | */ |
void write_cs_stats() | | void write_cs_stats() |
{ | | { |