Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members

FXSocketServer.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                  Socket server object                                         *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2003 by Mathew Robertson.   All Rights Reserved.                *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************/
00022 #ifndef FXSOCKETSERVER_H
00023 #define FXSOCKETSERVER_H
00024 
00025 #ifndef FXSOCKET_H
00026 #include "FXSocket.h"
00027 #endif
00028 namespace FXEX {
00029 #define BACKLOG 5
00030 
00031 /**
00032  * Provides TCP/UDP socket server functionality.
00033  * Defaults to UNIX domain socket if socket type is set to automatic.
00034  *
00035  * If you want the server to listen to a specific localhost address, such as may be the case
00036  * in a multi-home host, set the hostname() of the socket to the hostname / IP-address of
00037  * that interface, eg:
00038  *
00039  * socket=new FXSocketServer(...);
00040  * socket->hostname("localhost");  // thus only binds to 127.0.0.1
00041  */
00042 class FXAPI FXSocketServer : public FXSocket {
00043   FXDECLARE(FXSocketServer)
00044 
00045   protected:
00046     FXint backlog;   // number of incoming connections before blocking
00047 
00048   protected:
00049 
00050     /// for deserialisation
00051     FXSocketServer() {}
00052 
00053   public:
00054 
00055     /// connectors - by port
00056     FXSocketServer(FXApp *a,FXint port,FXint backLog=BACKLOG,FXObject* tgt=NULL,FXSelector sel=0,FXSocketFamily family=FXSocketFamilyInet,FXSocketType type=FXSocketTypeStream);
00057 
00058     /// connectors - by service
00059     FXSocketServer(FXApp *a,const FXString &service,FXint backLog=BACKLOG,FXObject* tgt=NULL,FXSelector sel=0,FXSocketFamily family=FXSocketFamilyInet,FXSocketType type=FXSocketTypeStream);
00060 
00061     /// create resources
00062     virtual FXbool open();
00063 
00064     /// save object to stream
00065     virtual void save(FXStream& store) const;
00066 
00067     /// load object from stream
00068     virtual void load(FXStream& store);
00069     
00070     /// dtor
00071     virtual ~FXSocketServer() {};
00072   };
00073 
00074 } // namespace FXEX
00075 #endif // FXSOCKETSERVER_H