00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef UDP_H
00015 #define UDP_H
00016
00017 #ifdef HAVE_CONFIG_H
00018 #include "config.h"
00019 #endif
00020
00021 #include <iostream>
00022
00023
00024 #include <netinet/in.h>
00025
00026 class UDP
00027 {
00028 public:
00029 UDP (unsigned int clientport, unsigned int serverport);
00030 UDP (char *hostaddr, unsigned int clientport, unsigned int serverport);
00031 ~UDP ();
00032
00033
00034 int recv (void *buf, int bufSize, unsigned long *from);
00035 int sendTo (unsigned long ipAddress, void *buf, int bufSize);
00036
00037
00038 int send (void *buf, int bufSize);
00039
00040 protected:
00041 UDP () { };
00042
00043 private:
00044 unsigned int clientport_;
00045 unsigned int serverport_;
00046
00047 struct sockaddr_in server_addr_;
00048 struct sockaddr_in client_addr_;
00049 bool isClient_;
00050
00051 public:
00052 int send_sd_;
00053 int recv_sd_;
00054 };
00055
00056 #endif // UDP_H