source: trunk/MagicSoft/Control/SubsystemIO/TCPListener.select.hxx@ 1239

Last change on this file since 1239 was 1053, checked in by casaldaliga, 23 years ago
renamed files to conform MAGIC standard
File size: 1.6 KB
Line 
1#ifndef TCPLISTENER
2#define TCPLISTENER
3
4#include <string>
5#include <sigc++/signal_system.h>
6
7using namespace SigC;
8//in Makefile#define MAXMSG 4096
9#include <netinet/in.h>
10//this is not properly a TCP server in the broadest sense (multiple clients). It should be called TCPListener(pending: change name consistently!). Only accepts connections from one client and responds driven by this client
11//TCPListener derives from libsigc++(signal/slot) Object to be able to connect signals to its methods
12class TCPListener: public Object {
13private:
14 int port;
15 bool newReceived;
16protected:
17 char receivedStream[MAXMSG];
18private:
19 char * clientAddress;
20 int clientPort;
21 //should be called commIsUp. Class Make up
22 bool comMode;
23 static void * Listening(void * self);
24
25public:
26 TCPListener (int port_);
27 ~TCPListener();
28protected:
29 //this public method should be capitalized for some consistency. Put the change should be propagated. class Make up!
30 virtual void process ();
31 string ReturnNew ();
32 virtual void ClosingChannel();
33private:
34 void Accept ();
35 void Receive (); //Syncronous receive. If you are not sure there will be data to read, schedule this receive with IONotifier or something. Otherwise it will block
36
37 pthread_t thread;
38 pthread_mutex_t mutex;
39// bool destroy;
40
41
42//server socket(the one which listens to incoming connections) file descriptor
43 int socketItself;
44//socket opened here to parter the incoming connection. This is the one used to communicate
45 int channel;
46 struct sockaddr_in socketAddr;
47
48};
49
50#endif
Note: See TracBrowser for help on using the repository browser.