InetUDPMaster.h

00001 /* Open SoundControl kit in C++                                              */
00002 /* Copyright (C) 2002-2004 libOSC++ contributors. See AUTHORS                */
00003 /*                                                                           */
00004 /* This library is free software; you can redistribute it and/or             */
00005 /* modify it under the terms of the GNU Lesser General Public                */
00006 /* License as published by the Free Software Foundation; either              */
00007 /* version 2.1 of the License, or (at your option) any later version.        */
00008 /*                                                                           */
00009 /* This library is distributed in the hope that it will be useful,           */
00010 /* but WITHOUT ANY WARRANTY; without even the implied warranty of            */
00011 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         */
00012 /* Lesser General Public License for more details.                           */
00013 /*                                                                           */
00014 /* You should have received a copy of the GNU Lesser General Public          */
00015 /* License along with this library; if not, write to the Free Software       */
00016 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
00017 /*                                                                           */
00018 /* For questions regarding this program contact                              */
00019 /* Daniel Holth <dholth@fastmail.fm> or visit                                */
00020 /* http://wiretap.stetson.edu/                                               */
00021 
00022 /*
00023  * This class was written by Martin Rumori (martin@rumori.de)
00024  */
00025 
00026 #ifndef LIBOSC_INETUDPMASTER_H
00027 #define LIBOSC_INETUDPMASTER_H
00028 
00029 #include "InetMaster.h"
00030 #include "InetTransportManager.h"
00031 #include "NullTransmit.h"
00032 
00033 #ifdef LIBOSC_REPLY
00034 #include "InetUDPReplier.h"
00035 #endif
00036 
00037 #include <sstream>
00038 #include <iosfwd>
00039 
00051 class InetUDPMaster : public InetMaster
00052 {
00053 #ifdef LIBOSC_REPLY
00054     friend class InetUDPReplier;
00055 #endif
00056 public:
00063   InetUDPMaster (InetOSCAddrType addrType = OSC_IN_IPv4);
00064 
00067   InetUDPMaster (InetUDPMaster &);
00068 
00070   virtual ~InetUDPMaster ();
00071 
00076   bool handle ();
00077 
00084   bool transmit(const std::string& data);
00085 
00094   bool transmitTo(struct sockaddr *address, const std::string &data);
00095 
00100   const int getHandle () const;
00101 
00112   bool setDestination (const std::string& host,
00113                        const short port);
00114 
00118   bool setReturnPort (const short port);
00119 
00134   bool startlisten (const short port);
00135 
00148   bool stoplisten ();
00149 
00159   bool setTransportManager (InetTransportManager *const transMan);
00160 
00165   void setProcessor (Processor *processor);
00166 
00171   bool isListening ();
00172 
00177   const std::string getStatusString (void);
00178 
00183   virtual std::string getName();
00184 
00185   virtual Transmit *clone ();
00186 
00187 protected:
00188 
00189 
00190 private:
00191 
00193   InetTransportManager *_transMan;
00194 
00196   Processor *_processor;
00197 
00199   bool _listening;
00200 
00202   short _port;
00203 
00205   struct sockaddr *_remoteSendAddr;
00206 
00208   struct sockaddr *_remoteRecvAddr;
00209 
00211   socklen_t _addrlen;
00212 
00214   char _rbuf[OSC_DGRAM_MAXLENGTH];
00215 
00216 };
00217 
00218 #endif // #ifndef LIBOSC_INETUDPMASTER_H

Generated on Thu Mar 2 23:51:35 2006 for libOSC++ by  doxygen 1.4.6