+
+ if (client->buf_tail >= client->buf_head) {
+ bytes_read = xread (client->socket,
+ client->buf,
+ TTT_CLIENT_BUF_SIZE);
+ if (bytes_read == 0)
+ return TTT_STATUS_EOF;
+ client->buf_head = client->buf;
+ client->buf_tail = client->buf_head + bytes_read;
+ }
+
+ for (s = client->buf_head; s < client->buf_tail; s++) {
+ if (*s == delimeter) {
+ found_delimeter = TRUE;
+ s++;
+ break;
+ }
+ }
+
+ _append_to_request (client,
+ client->buf_head,
+ s - client->buf_head);
+ client->buf_head = s;
+
+ if (found_delimeter)
+ return TTT_STATUS_SUCCESS;
+ }
+}
+
+static ttt_status_t
+_read_request (ttt_client_t *client)
+{
+ ttt_status_t status;
+ static const char null_terminator = '\0';
+
+ status = _read_into_request_until (client, '\n');
+ if (status)
+ return status;
+
+ _append_to_request (client, &null_terminator, 1);
+
+ return TTT_STATUS_SUCCESS;
+}
+
+static ttt_error_t
+_execute_request (ttt_client_t *client)
+{
+ ttt_server_broadcast (client->server, client->request);
+
+ return TTT_ERROR_NONE;
+}
+
+static void *
+_handle_requests_thread (void *closure)
+{
+ ttt_status_t status;
+ ttt_error_t error;
+ ttt_client_t *client = closure;
+
+ while (1) {
+
+ status = _read_request (client);
+ if (status == TTT_STATUS_EOF)