VR-Forces 4.0.4 Class Documentation
include/vrvCore/DtTcpServer.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002 ** Copyright (c) 2009 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 *******************************************************************************/
00005 /*******************************************************************************
00006 ** $RCSfile: DtTcpServer.h,v $ $Revision: 1.25 $ $State: Exp $
00007 *******************************************************************************/
00008 
00012 
00013 #ifndef DtIGITCPServer_H_
00014 #define DtIGITCPServer_H_
00015 
00016 #include <vrvCore/vrvCore.h>
00017 
00018 #include <list>
00019 #include <string>
00020 
00021 #ifdef _WIN32
00022 struct fd_set;
00023 #else
00024 #include <sys/types.h>
00025 #endif
00026 
00027 
00028 namespace makVrv
00029 {
00030    class DtDe;
00031    class DtMessageDispatcher;
00032    class DtTcpMessageClient;
00033 
00036    class DT_DLL_VRVCORE DtTcpServer
00037    {
00038    public:
00039 
00040       typedef std::list<DtTcpMessageClient*> ClientList;
00041 
00042       static const std::string theServerHandshake;
00043       static const std::string theClientHandshake;
00044 
00046       DtTcpServer(DtDe& de,int port);
00047 
00049       ~DtTcpServer();
00050 
00052       bool isListening() const;
00053 
00055       void startListening();
00056 
00058       void stopListening();
00059 
00061       int numberOfConnections();
00062 
00064       void checkForMessages();
00065 
00069       void addClient(DtTcpMessageClient*);
00070 
00072       const ClientList& clients() const;
00073 
00075       void deleteClient(DtTcpMessageClient*);
00076 
00078       DtTcpMessageClient* findClient(const std::string& name);
00079 
00081       void deleteClients();     
00082 
00084       static void setBlocking(int fd, bool blocking);
00085 
00086    protected:
00087 
00089       void handleNewConnections();
00090 
00092       void buildSocketList();
00093       
00095       void processReads();      
00096       
00097 
00098       DtDe& myDe;
00099       int mySocket;
00100       int myHighSocket;
00101       int myPort;
00102       fd_set* myReceiveSet;
00103       
00104       ClientList myClients;
00105       DtMessageDispatcher& myDispatcher;
00106    };
00107 }
00108 
00109 #endif

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)