Async  0.18.0
AsyncUdpSocket.h
Go to the documentation of this file.
1 
34 #ifndef ASYNC_UDP_SOCKET_INCLUDED
35 #define ASYNC_UDP_SOCKET_INCLUDED
36 
37 
38 /****************************************************************************
39  *
40  * System Includes
41  *
42  ****************************************************************************/
43 
44 #include <sigc++/sigc++.h>
45 #include <stdint.h>
46 
47 
48 /****************************************************************************
49  *
50  * Project Includes
51  *
52  ****************************************************************************/
53 
54 
55 
56 /****************************************************************************
57  *
58  * Local Includes
59  *
60  ****************************************************************************/
61 
62 
63 
64 /****************************************************************************
65  *
66  * Forward declarations
67  *
68  ****************************************************************************/
69 
70 class UdpPacket;
71 
72 
73 /****************************************************************************
74  *
75  * Namespace
76  *
77  ****************************************************************************/
78 
79 namespace Async
80 {
81 
82 
83 /****************************************************************************
84  *
85  * Forward declarations of classes inside of the declared namespace
86  *
87  ****************************************************************************/
88 
89 class FdWatch;
90 class IpAddress;
91 
92 
93 /****************************************************************************
94  *
95  * Defines & typedefs
96  *
97  ****************************************************************************/
98 
99 
100 
101 /****************************************************************************
102  *
103  * Exported Global Variables
104  *
105  ****************************************************************************/
106 
107 
108 
109 /****************************************************************************
110  *
111  * Class definitions
112  *
113  ****************************************************************************/
114 
124 class UdpSocket : public SigC::Object
125 {
126  public:
132  UdpSocket(uint16_t local_port=0);
133 
137  ~UdpSocket(void);
138 
147  bool initOk(void) const { return (sock != -1); }
148 
157  bool write(const IpAddress& remote_ip, int remote_port, const void *buf,
158  int count);
159 
166  SigC::Signal3<void, const IpAddress&, void *, int> dataReceived;
167 
173  SigC::Signal1<void, bool> sendBufferFull;
174 
175  protected:
176 
177  private:
178  int sock;
179  FdWatch * rd_watch;
180  FdWatch * wr_watch;
181  UdpPacket * send_buf;
182 
183  void cleanup(void);
184  void handleInput(FdWatch *watch);
185  void sendRest(FdWatch *watch);
186 
187 }; /* class UdpSocket */
188 
189 
190 } /* namespace */
191 
192 #endif /* ASYNC_UDP_SOCKET_INCLUDED */
193 
194 
195 
196 /*
197  * This file has not been truncated
198  */
199 
SigC::Signal3< void, const IpAddress &, void *, int > dataReceived
A signal that is emitted when data has been received.
SigC::Signal1< void, bool > sendBufferFull
A signal that is emitted when the send buffer is full.
~UdpSocket(void)
Destructor.
bool write(const IpAddress &remote_ip, int remote_port, const void *buf, int count)
Write data to the remote host.
bool initOk(void) const
Check if the initialization was ok.
UdpSocket(uint16_t local_port=0)
Constructor.
A class for watching file descriptors.
Definition: AsyncFdWatch.h:119
A class for working with UDP sockets.
A class for representing an IP address in an OS independent way.