00001 /* 00002 CLAW - a C++ Library Absolutely Wonderful 00003 00004 CLAW is a free library without any particular aim but being useful to 00005 anyone. 00006 00007 Copyright (C) 2005-2008 Julien Jorge 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2.1 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 00020 License along with this library; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00022 00023 contact: julien_jorge@yahoo.fr 00024 */ 00030 #include <claw/socket_server.hpp> 00031 #include <sys/types.h> 00032 00033 /*----------------------------------------------------------------------------*/ 00038 claw::net::socket_server::socket_server() 00039 { 00040 // nothing to do 00041 } // socket_server::socket_server() 00042 00043 /*----------------------------------------------------------------------------*/ 00049 claw::net::socket_server::socket_server( int port, unsigned int queue_size ) 00050 { 00051 open(port, queue_size); 00052 } // socket_server::socket_server() 00053 00054 /*----------------------------------------------------------------------------*/ 00061 claw::net::socket_server::socket_server* 00062 claw::net::socket_server::open( int port, unsigned int queue_size ) 00063 { 00064 socket_server* result = NULL; 00065 00066 if ( basic_socket::open() ) 00067 { 00068 if ( !socket_traits::listen(m_descriptor, port, queue_size) ) 00069 basic_socket::close(); 00070 else 00071 result = this; 00072 } 00073 00074 return result; 00075 } // socket_server::open() 00076 00077 /*----------------------------------------------------------------------------*/ 00081 claw::net::socket_server::socket_server* claw::net::socket_server::close() 00082 { 00083 if ( basic_socket::close() ) 00084 return this; 00085 else 00086 return NULL; 00087 } // socket_server::close() 00088 00089 /*----------------------------------------------------------------------------*/ 00093 bool claw::net::socket_server::is_open() const 00094 { 00095 return basic_socket::is_open(); 00096 } // socket_server::is_open() 00097 00098 /*----------------------------------------------------------------------------*/ 00102 claw::net::socket_server::operator bool() const 00103 { 00104 return is_open(); 00105 } // socket_server::operator bool() 00106 00107 /*----------------------------------------------------------------------------*/ 00112 bool claw::net::socket_server::init() 00113 { 00114 return socket_traits::init(); 00115 } // socket_server::init() 00116 00117 /*----------------------------------------------------------------------------*/ 00122 bool claw::net::socket_server::release() 00123 { 00124 return socket_traits::release(); 00125 } // socket_server::release()