Mercurial > hg > beaglert
view include/client.h @ 44:f5b5c648cd5d ultra-staging
- added (unused) simple c++ classes for udp datagrams\n- added tests for the new classes
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Wed, 20 May 2015 18:07:16 +0100 |
parents | 4255ecbb9bec |
children | d3f869b98147 |
line wrap: on
line source
/* UDP client in the internet domain */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> struct networkData{ int *counter; float *variables[16]; int numVariables; }; #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 struct networkAudio{ int timestamp; int currentBuffer; int index; float buffers[2][NETWORK_AUDIO_BUFFER_SIZE]; int doneOnTime; }; void error(const char *); int setupSockets(int receivePort, int transmitPort, char const*serverName); int sendMessage(networkData message); int sendAudio(networkAudio *audio); int receiveMessage(networkData message); void closeSockets();