UdpClient.h
1 /*
2  * udpClient.h
3  *
4  * Created on: 19 May 2015
5  * Author: giulio moro
6  */
7 
8 #ifndef UDPCLIENT_H_
9 #define UDPCLIENT_H_
10 
11 #include <sys/types.h>
12 #include <sys/socket.h>
13 #include <netinet/in.h>
14 #include <arpa/inet.h>
15 #include <netdb.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <unistd.h>
19 #include <string.h>
20 
21 class UdpClient{
22  private:
23  int port;
24  int enabled;
25  int outSocket;
26  struct timeval stTimeOut;
27  fd_set stWriteFDS;
28  bool isSetPort;
29  bool isSetServer;
30  struct sockaddr_in destinationServer;
31  public:
32  UdpClient();
33  UdpClient(int aPort, const char* aServerName);
34  ~UdpClient();
35  void setPort(int aPort);
36  void setServer(const char* aServerName);
37  int send(void* message, int size);
38  int write(const char* remoteHostname, int remotePortNumber, void* sourceBuffer, int numBytesToWrite);
39  int waitUntilReady(bool readyForReading, int timeoutMsecs);
40  int setSocketBroadcast(int broadcastEnable);
41 };
42 
43 
44 
45 #endif /* UDPCLIENT_H_ */
Definition: UdpClient.h:21