| | 133 | // UdpListeningReceiveSocket provides a simple way to bind one listener |
|---|
| | 134 | // to a single socket without having to manually set up a SocketReceiveMultiplexer |
|---|
| | 135 | |
|---|
| | 136 | class UdpListeningReceiveSocket : public UdpSocket{ |
|---|
| | 137 | SocketReceiveMultiplexer mux_; |
|---|
| | 138 | PacketListener *listener_; |
|---|
| | 139 | public: |
|---|
| | 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 | |
|---|