Mercurial > hg > beaglert
annotate include/client.h @ 54:d3f869b98147 ultra-staging
Udp transmission working (enough) for demo in Nottingham
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Mon, 08 Jun 2015 01:07:48 +0100 |
parents | 4255ecbb9bec |
children |
rev | line source |
---|---|
giuliomoro@24 | 1 /* UDP client in the internet domain */ |
giuliomoro@24 | 2 #include <sys/types.h> |
giuliomoro@24 | 3 #include <sys/socket.h> |
giuliomoro@24 | 4 #include <netinet/in.h> |
giuliomoro@24 | 5 #include <arpa/inet.h> |
giuliomoro@24 | 6 #include <netdb.h> |
giuliomoro@24 | 7 #include <stdio.h> |
giuliomoro@24 | 8 #include <stdlib.h> |
giuliomoro@24 | 9 #include <unistd.h> |
giuliomoro@24 | 10 #include <string.h> |
giuliomoro@24 | 11 |
giuliomoro@24 | 12 struct networkData{ |
giuliomoro@24 | 13 int *counter; |
giuliomoro@24 | 14 float *variables[16]; |
giuliomoro@24 | 15 int numVariables; |
giuliomoro@24 | 16 }; |
giuliomoro@41 | 17 #define NETWORK_AUDIO_BUFFER_SIZE 100 //1400/4 //maximum payload for a UDP datagram over ethernet is 1472 bytes, I leave some headroom and divide by 4 to get the number of floats |
giuliomoro@41 | 18 struct networkAudio{ |
giuliomoro@41 | 19 int timestamp; |
giuliomoro@41 | 20 int currentBuffer; |
giuliomoro@41 | 21 int index; |
giuliomoro@41 | 22 float buffers[2][NETWORK_AUDIO_BUFFER_SIZE]; |
giuliomoro@41 | 23 int doneOnTime; |
giuliomoro@54 | 24 bool toBeSent; |
giuliomoro@54 | 25 UdpClient udpClient; |
giuliomoro@41 | 26 }; |
giuliomoro@24 | 27 |
giuliomoro@24 | 28 void error(const char *); |
giuliomoro@24 | 29 int setupSockets(int receivePort, int transmitPort, char const*serverName); |
giuliomoro@24 | 30 int sendMessage(networkData message); |
giuliomoro@41 | 31 int sendAudio(networkAudio *audio); |
giuliomoro@24 | 32 int receiveMessage(networkData message); |
giuliomoro@24 | 33 void closeSockets(); |