Show
Ignore:
Timestamp:
09/22/05 12:36:59 (3 years ago)
Author:
ross
Message:

added UdpListeningReceiveSocket? convenience class

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • oscpack/trunk/ip/UdpSocket.h

    r16 r19  
    131131 
    132132 
     133// UdpListeningReceiveSocket provides a simple way to bind one listener 
     134// to a single socket without having to manually set up a SocketReceiveMultiplexer 
     135 
     136class UdpListeningReceiveSocket : public UdpSocket{ 
     137    SocketReceiveMultiplexer mux_; 
     138    PacketListener *listener_; 
     139public: 
     140  UdpListeningReceiveSocket( const IpEndpointName& localEndpoint, PacketListener *listener ) 
     141        : listener_( listener ) 
     142    { 
     143        Bind( localEndpoint ); 
     144        mux_.AttachSocketListener( this, listener_ ); 
     145    } 
     146 
     147    ~UdpListeningReceiveSocket() 
     148        { mux_.DetachSocketListener( this, listener_ ); } 
     149 
     150    // see SocketReceiveMultiplexer above for the behaviour of these methods... 
     151    void Run() { mux_.Run(); } 
     152  void RunUntilSigInt() { mux_.RunUntilSigInt(); } 
     153    void Break() { mux_.Break(); } 
     154    void AsynchronousBreak() { mux_.AsynchronousBreak(); } 
     155}; 
     156 
     157 
    133158#endif /* INCLUDED_UDPSOCKET_H */