2 * Copyright (C) ARM Limited 2014. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
9 #include "AnnotateListener.h"
13 #include "OlySocket.h"
15 struct AnnotateClient {
20 AnnotateListener::AnnotateListener() : mClients(NULL), mSock(NULL) {
23 AnnotateListener::~AnnotateListener() {
28 void AnnotateListener::setup() {
29 mSock = new OlyServerSocket(8082);
32 int AnnotateListener::getFd() {
33 return mSock->getFd();
36 void AnnotateListener::handle() {
37 AnnotateClient *const client = new AnnotateClient();
38 client->fd = mSock->acceptConnection();
39 client->next = mClients;
43 void AnnotateListener::close() {
44 mSock->closeServerSocket();
45 while (mClients != NULL) {
46 ::close(mClients->fd);
47 AnnotateClient *next = mClients->next;
53 void AnnotateListener::signal() {
55 AnnotateClient **ptr = &mClients;
56 AnnotateClient *client = mClients;
57 while (client != NULL) {
58 if (write(client->fd, &ch, sizeof(ch)) != 1) {
60 AnnotateClient *next = client->next;
67 client = client->next;