00001 /* --------------------------------------------------------------------------- 00002 Phission : 00003 Realtime Vision Processing System 00004 00005 Copyright (C) 2003-2006 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 Lesser 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 Lesser General Public License for more details. 00020 00021 You should have received a copy of the GNU Lesser 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 * phServerSocket.h: C++ Wrapper class for server socket programming * 00028 * * 00029 * -------------------------------------------------------------------------- * 00030 * This code is mostly from the Phission code base. * 00031 * This code was originally coded by John R. Watson in the Fall of 2003-2006 and * 00032 * added to Phission by myself. Since then I've added some necessary * 00033 * functionality for use in a streaming JPEG/Image server/client for Phission.* 00034 * I'm using it here to further stretch/test it's functionality * 00035 * -------------------------------------------------------------------------- */ 00036 #ifndef _PHSERVERSOCKET_H 00037 #define _PHSERVERSOCKET_H 00038 00039 #include <phStandard.h> 00040 #include <phSocket.h> 00041 00042 /* ---------------------------------------------------------------------- */ 00046 /* ------------------------------------------------------------------------ */ 00052 PHAPI(class) phServerSocket : protected phSocket 00053 { 00054 private: 00055 /* The number of pending client connections allowed on an 00056 * accepting socket */ 00057 int m_backlog; 00058 00059 phMutex m_accept_lock; 00060 00061 public: 00062 phServerSocket( int port = 0, int backlog = 1 ); 00063 ~phServerSocket(); 00064 00069 int copy( phObject *copyto_obj ); 00074 int swap( phObject *obj ); 00075 00076 /* The following four methods allow thread safe access to the 00077 * phServerSocket's member variables */ 00078 int setPort( int port ); 00079 int getPort(); 00080 00081 /* Backlog is the number of pending client connections there 00082 * can be on a socket that we're performing accepts on */ 00083 int setBackLog( int backlog ); 00084 int getBackLog(); 00085 00086 /* Wrap the phSocket 'block' and 'wakeup' calls so we can 00087 * keep the rest of the inherited phSocket methods protected */ 00088 /* This sets whether we should block on socket calls */ 00089 int setBlocking( int set_blocking = phBLOCK ); 00090 00091 /* Try to wake up a phServerSocket if it's blocking on something, 00092 * this isn't gauranteed to work */ 00093 void wakeup(); 00094 00095 int isSockValid(); 00096 00097 /* listen -- create a socket and listen on port for connections */ 00098 int listen( const int port = -1, const int backlog = -1 ); 00099 00100 /* accept -- accept a client connection */ 00101 /* m_exit_trigger will preempt the accept loop and return */ 00102 phSocket *accept(); 00103 00104 virtual int print_object( FILE *fd ); 00105 }; 00106 00107 #endif /* _PHSERVERSOCKET_H */
| Copyright (C) 2002 - 2007 |
Philip D.S. Thoren ( pthoren@users.sourceforge.net ) University Of Massachusetts at Lowell Robotics Lab |
|
1.4.4