Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Files Functions Variables Typedefs Macros Groups
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 outSocket;
25  struct timeval stTimeOut;
26  fd_set stWriteFDS;
27  bool enabled = false;
28  bool isSetPort = false;
29  bool isSetServer = false;
30  struct sockaddr_in destinationServer;
31  public:
32  UdpClient();
33  UdpClient(int aPort, const char* aServerName);
34  ~UdpClient();
35  bool setup(int aPort, const char* aServerName);
36  void cleanup();
43  void setPort(int aPort);
44 
51  void setServer(const char* aServerName);
52 
61  int send(void* message, int size);
62 
63  int write(const char* remoteHostname, int remotePortNumber, void* sourceBuffer, int numBytesToWrite);
64  int waitUntilReady(bool readyForReading, int timeoutMsecs);
65  int setSocketBroadcast(int broadcastEnable);
66 };
67 
68 
69 
70 #endif /* UDPCLIENT_H_ */
void setPort(int aPort)
Definition: UdpClient.cpp:37
void cleanup(BelaContext *context, void *userData)
User-defined cleanup function which runs when the program finishes.
Definition: render.cpp:82
bool setup(BelaContext *context, void *userData)
User-defined initialisation function which runs before audio rendering begins.
Definition: render.cpp:36
int send(void *message, int size)
Definition: UdpClient.cpp:55
Definition: UdpClient.h:21
void setServer(const char *aServerName)
Definition: UdpClient.cpp:47