00001 00034 #ifndef ASYNC_UDP_SOCKET_INCLUDED 00035 #define ASYNC_UDP_SOCKET_INCLUDED 00036 00037 00038 /**************************************************************************** 00039 * 00040 * System Includes 00041 * 00042 ****************************************************************************/ 00043 00044 #include <sigc++/signal_system.h> 00045 00046 00047 /**************************************************************************** 00048 * 00049 * Project Includes 00050 * 00051 ****************************************************************************/ 00052 00053 00054 00055 /**************************************************************************** 00056 * 00057 * Local Includes 00058 * 00059 ****************************************************************************/ 00060 00061 00062 00063 /**************************************************************************** 00064 * 00065 * Forward declarations 00066 * 00067 ****************************************************************************/ 00068 00069 class UdpPacket; 00070 00071 00072 /**************************************************************************** 00073 * 00074 * Namespace 00075 * 00076 ****************************************************************************/ 00077 00078 namespace Async 00079 { 00080 00081 00082 /**************************************************************************** 00083 * 00084 * Forward declarations of classes inside of the declared namespace 00085 * 00086 ****************************************************************************/ 00087 00088 class FdWatch; 00089 class IpAddress; 00090 00091 00092 /**************************************************************************** 00093 * 00094 * Defines & typedefs 00095 * 00096 ****************************************************************************/ 00097 00098 00099 00100 /**************************************************************************** 00101 * 00102 * Exported Global Variables 00103 * 00104 ****************************************************************************/ 00105 00106 00107 00108 /**************************************************************************** 00109 * 00110 * Class definitions 00111 * 00112 ****************************************************************************/ 00113 00123 class UdpSocket : public SigC::Object 00124 { 00125 public: 00131 UdpSocket(unsigned short local_port=0); 00132 00136 ~UdpSocket(void); 00137 00146 bool initOk(void) const { return (sock != -1); } 00147 00156 bool write(const IpAddress& remote_ip, int remote_port, const void *buf, 00157 int count); 00158 00165 SigC::Signal3<void, const IpAddress&, void *, int> dataReceived; 00166 00172 SigC::Signal1<void, bool> sendBufferFull; 00173 00174 protected: 00175 00176 private: 00177 int sock; 00178 FdWatch * rd_watch; 00179 FdWatch * wr_watch; 00180 UdpPacket * send_buf; 00181 00182 void cleanup(void); 00183 void handleInput(FdWatch *watch); 00184 void sendRest(FdWatch *watch); 00185 00186 }; /* class UdpSocket */ 00187 00188 00189 } /* namespace */ 00190 00191 #endif /* ASYNC_UDP_SOCKET_INCLUDED */ 00192 00193 00194 00195 /* 00196 * This file has not been truncated 00197 */ 00198
1.4.4