Update Turkish translation
[dasher.git] / Src / DasherCore / SocketInput.h
blobe7e047988b3a8e6cd3dfda78743aac8777deaed8
1 // SocketInput.h
2 //
3 // (C) Copyright Seb Wills 2005
4 //
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 "./Observable.h"
13 #include <iostream>
14 #include <pthread.h>
16 #define GCC_VERSION (__GNUC__ * 10000 \
17 + __GNUC_MINOR__ * 100 \
18 + __GNUC_PATCHLEVEL__)
22 namespace Dasher {
23 class CSocketInput;
24 #if GCC_VERSION >= 40100
25 void *ThreadLauncherStub(void *_myClass);
26 #endif
28 using namespace std;
29 /// \ingroup Input
30 /// \{
31 class CSocketInput:public CSocketInputBase {
33 // This non-member launcher stub function is required because pthreads can't launch a non-static member method.
34 friend void *ThreadLauncherStub(void *_myClass) {
35 CSocketInput *myClass = (CSocketInput *) _myClass;
37 pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); // kill this thread immediately if another thread cancels it
38 // don't know how this interacts with recv blocking
40 myClass->ReadForever();
42 return NULL;
45 public:
47 CSocketInput(CSettingsUser *pCreator, CMessageDisplay *pMsgs);
48 ~CSocketInput();
50 private:
52 pthread_t readerThread;
54 bool LaunchReaderThread();
56 void CancelReaderThread();
58 // TODO: should probably override ReportErrnoError() to popup a Gtk error message
62 /// \}
63 #endif