Project

General

Profile

Revision 14

Added by Jason knichel over 15 years ago

added a write function to the connection pool

View differences:

ConnectionPool.cpp
219 219
  return 0;
220 220
}
221 221

  
222
int ConnectionPool::write_to_client(int pool_index, char * message, int length) {
223
  //TODO: put error checking on pool_index, message, length
224
  if (length > (WRITE_BUFFER_SIZE-write_buffer_size[pool_index]))
225
    {
226
      //TODO: make this a logging statement instead of a print statement
227
      printf("There is not enough room in the write buffer to send the data to the client.\n");
228
      return -1;
229
    }
222 230

  
231
  memcpy(write_buffer[pool_index], message, length);
232
  write_buffer_size[pool_index] += length;
233

  
234
  return 0;
235
}
236

  
237

  
223 238
//TODO: put error checking on listen_socket to make sure its a valid socket
224 239
void ConnectionPool::set_listen_socket_in_ready_set(int listen_socket) {
225 240
  FD_SET(listen_socket, &ready_set);
......
286 301
  write_set = new_set;
287 302
}
288 303

  
289
//TODO: remove after a write_to_client or similar method is written so this won't be needed anymore
290
int ConnectionPool::get_write_buffer_size(int pool_index) {
291
  return write_buffer_size[pool_index];
292
}
293

  
294
//TODO: remove after a write_to_client or similar method is written so this won't be needed anymore
295
void ConnectionPool::set_write_buffer_size(int pool_index, int new_buffer_size) {
296
  write_buffer_size[pool_index] = new_buffer_size;
297
}
298

  
299
//TODO: remove after a write_to_client or similar method is written so this won't be needed anymore
300
char * ConnectionPool::get_write_buffer(int pool_index) {
301
  return write_buffer[pool_index];
302
}
303

  
304 304
//TODO: write a function to write data into the write buffers
305 305
//TODO: fix names of variables to obey new style
306 306
int ConnectionPool::parse_command(char* command, int pool_index) {

Also available in: Unified diff