rllib  1
Classes | Functions
rleventlogserver.cpp File Reference
#include "rlsocket.h"
#include "rleventlogserver.h"
#include "rlcutil.h"
#include "rltime.h"
#include "stdio.h"
#include "string.h"
Include dependency graph for rleventlogserver.cpp:

Go to the source code of this file.

Classes

struct  WORKER_DATA
 

Functions

static void * workerThread (void *arg)
 
static void * rlAcceptThread (void *arg)
 

Function Documentation

◆ rlAcceptThread()

static void* rlAcceptThread ( void *  arg)
static

Definition at line 151 of file rleventlogserver.cpp.

152 {
153  int port,s;
154  rlThread worker;
155  WORKER_DATA worker_data;
156  rlEventLogServerThreads *thread;
157  rlSocket *socket;
158  THREAD_PARAM *p = (THREAD_PARAM *) arg;
159 
160  thread = (rlEventLogServerThreads *) p->user;
161  port = thread->getPort();
162  socket = new rlSocket("localhost",port,0);
163  while(1)
164  {
165  s = socket->connect();
166  if(s == -1) break;
167  worker_data.thread = thread;
168  worker_data.socket = s;
169  worker.create(workerThread,&worker_data);
170  rlsleep(100);
171  }
172  delete socket;
173  return NULL;
174 }
void * user
Definition: rlthread.h:30
int create(void *(*func)(void *), void *argument)
Definition: rlthread.cpp:35
static void * workerThread(void *arg)
void rlsleep(long msec)
Definition: rlwthread.cpp:396
int connect()
Definition: rlsocket.cpp:321
rlDataProviderThreads * thread

◆ workerThread()

static void* workerThread ( void *  arg)
static

Definition at line 128 of file rleventlogserver.cpp.

129 {
130  char message[rlMAX_EVENT];
131  int s,ret;
132  WORKER_DATA *worker_data;
133  rlEventLogServerThreads *thread;
134  rlSocket *socket;
135 
136  THREAD_PARAM *p = (THREAD_PARAM *) arg;
137  worker_data = (WORKER_DATA *) p->user;
138  s = worker_data->socket;
139  thread = worker_data->thread;
140  socket = new rlSocket(s);
141 
142  while(socket->isConnected())
143  {
144  ret = socket->readStr(message,sizeof(message)-1);
145  if(ret > 0) thread->event_log_server->putEvent(message);
146  }
147  delete socket;
148  return NULL;
149 }
void putEvent(const char *event)
#define rlMAX_EVENT
Definition: rlevent.h:26
void * user
Definition: rlthread.h:30
int readStr(char *buf, int len, int timeout=0)
Definition: rlsocket.cpp:224
int isConnected()
Definition: rlsocket.cpp:559
rlDataProviderThreads * thread
rlEventLogServer * event_log_server