Mercurial > hg > beaglert
annotate include/UdpClient.h @ 556:ce391098f321 prerelease tip
THIS PROJECT HAS MOVED TO https://github.com/BelaPlatform/bela
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sat, 25 Jun 2016 20:21:00 +0100 |
parents | 6599a9978ac4 |
children |
rev | line source |
---|---|
andrewm@70 | 1 /* |
andrewm@70 | 2 * udpClient.h |
andrewm@70 | 3 * |
andrewm@70 | 4 * Created on: 19 May 2015 |
andrewm@70 | 5 * Author: giulio moro |
andrewm@70 | 6 */ |
andrewm@70 | 7 |
andrewm@70 | 8 #ifndef UDPCLIENT_H_ |
andrewm@70 | 9 #define UDPCLIENT_H_ |
andrewm@70 | 10 |
andrewm@70 | 11 #include <sys/types.h> |
andrewm@70 | 12 #include <sys/socket.h> |
andrewm@70 | 13 #include <netinet/in.h> |
andrewm@70 | 14 #include <arpa/inet.h> |
andrewm@70 | 15 #include <netdb.h> |
andrewm@70 | 16 #include <stdio.h> |
andrewm@70 | 17 #include <stdlib.h> |
andrewm@70 | 18 #include <unistd.h> |
andrewm@70 | 19 #include <string.h> |
andrewm@70 | 20 |
andrewm@70 | 21 class UdpClient{ |
andrewm@70 | 22 private: |
andrewm@70 | 23 int port; |
andrewm@70 | 24 int enabled; |
andrewm@70 | 25 int outSocket; |
giuliomoro@217 | 26 struct timeval stTimeOut; |
giuliomoro@336 | 27 fd_set stWriteFDS; |
andrewm@70 | 28 bool isSetPort; |
andrewm@70 | 29 bool isSetServer; |
andrewm@70 | 30 struct sockaddr_in destinationServer; |
andrewm@70 | 31 public: |
andrewm@70 | 32 UdpClient(); |
andrewm@70 | 33 UdpClient(int aPort, const char* aServerName); |
andrewm@70 | 34 ~UdpClient(); |
andrewm@70 | 35 void setPort(int aPort); |
andrewm@70 | 36 void setServer(const char* aServerName); |
andrewm@70 | 37 int send(void* message, int size); |
giuliomoro@217 | 38 int write(const char* remoteHostname, int remotePortNumber, void* sourceBuffer, int numBytesToWrite); |
giuliomoro@336 | 39 int waitUntilReady(bool readyForReading, int timeoutMsecs); |
giuliomoro@336 | 40 int setSocketBroadcast(int broadcastEnable); |
andrewm@70 | 41 }; |
andrewm@70 | 42 |
andrewm@70 | 43 |
andrewm@70 | 44 |
andrewm@70 | 45 #endif /* UDPCLIENT_H_ */ |