Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

phClientListener.h

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002     Phission : 
00003         Realtime Vision Processing System
00004 
00005     Copyright (C) 2003 Philip D.S. Thoren (pthoren@cs.uml.edu)
00006     University of Massachusetts at Lowell,
00007     Laboratory for Artificial Intelligence and Robotics
00008 
00009     This file is part of Phission.
00010 
00011     Phission is free software; you can redistribute it and/or modify
00012     it under the terms of the GNU General Public License as published by
00013     the Free Software Foundation; either version 2 of the License, or
00014     (at your option) any later version.
00015 
00016     Phission is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019     GNU General Public License for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with Phission; if not, write to the Free Software
00023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024 
00025  ---------------------------------------------------------------------------*/
00026 /* -------------------------------------------------------------------------- *
00027  * phClientListener.h: Thread class to handle all the server's responsibilities *                                                                            *
00028  * --------------------------------------------------------------------------*/
00029 #ifndef PHCLIENTLISTENER_H
00030 #define PHCLIENTLISTENER_H
00031 
00032 #include <phission.h>
00033 #include <phClientHandler.h>
00034 #include <phLamportSystem.h>
00035 
00036 /* -------------------------------------------------------------------------- */
00037 class phClientListener : public phThread
00038 {
00039 private:
00040     phLamportSystem *m_system;
00041     
00042     /* This is the port to set in the phServerSocket class for listening
00043      * for client connection requests */
00044     int m_port;
00045 
00046     char    *m_host;
00047     int     m_host_size;
00048     
00049     int     m_controller_id;
00050 
00051     uint32_t m_client_count;
00052 
00053     phClientHandler **m_threads;
00054     uint32_t m_thread_count;
00055     
00056     /* The server object that implements the socket communications */
00057     phServerSocket *m_server;
00058 
00059 public:
00060 
00061     phClientListener(int controller_id      = -1, 
00062                      int port               = 0, 
00063                      char *host             = NULL,
00064                      phLamportSystem *system= NULL );
00065     virtual ~phClientListener();
00066 
00067     /* member variable access methods */
00068     int setPort(int port = 0);
00069     int getPort();
00070         
00071     int setHost(char *host);
00072     char *getHost();
00073 
00074     int setControllerId(int controller_id);
00075     int getControllerId();
00076 
00077     int setSystem( phLamportSystem *system );
00078     phLamportSystem *getSystem();
00079     
00080     int joinClientThreads( );
00081     int addClientThread( phClientHandler *client );
00082      
00083     /* run: where the server object is used to listen for requests and
00084      * spawn phClientHandlers to handle those requests */
00085     virtual int run();
00086     /* wakeup: tries to get the waiting server accepts to return and
00087      * also sets variables so that the thread can wakeup and finish */
00088     virtual int wakeup();
00089     /* cleanup: delete, reset any variables to allow reuse of this object */
00090     virtual int cleanup();
00091     /* error: this doesn't do much, it's here if anything needs to be
00092      * done if the thread has an error condition starting up */
00093     virtual int error();
00094 };
00095 
00096 
00097 #endif /* PHCLIENTLISTENER_H */




Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:44:05 2007 for phission by  doxygen 1.4.4