3 // (C) Copyright Seb Wills 2005
5 // Linux-specific subclass of SocketInputBase: provides network socket control of Dasher cursor
7 #ifndef __SocketInput_h__
8 #define __SocketInput_h__
10 #include "./SocketInputBase.h"
11 #include "./DasherComponent.h"
12 #include "./EventHandler.h"
17 #define GCC_VERSION (__GNUC__ * 10000 \
18 + __GNUC_MINOR__ * 100 \
19 + __GNUC_PATCHLEVEL__)
25 #if GCC_VERSION >= 40100
26 void *ThreadLauncherStub(void *_myClass
);
30 using namespace Dasher
;
33 class Dasher::CSocketInput
:public CSocketInputBase
{
35 // This non-member launcher stub function is required because pthreads can't launch a non-static member method.
36 friend void *ThreadLauncherStub(void *_myClass
) {
37 CSocketInput
*myClass
= (CSocketInput
*) _myClass
;
39 pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS
, NULL
); // kill this thread immediately if another thread cancels it
40 // don't know how this interacts with recv blocking
42 myClass
->ReadForever();
49 CSocketInput(CEventHandler
* pEventHandler
, CSettingsStore
* pSettingsStore
);
54 pthread_t readerThread
;
56 bool LaunchReaderThread();
58 void CancelReaderThread();
60 // TODO: should probably override ReportErrnoError() to popup a Gtk error message