view include/client.h @ 41:4255ecbb9bec ultra-staging

Timers to measure performances, ultra experimental
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 19 May 2015 16:41:07 +0100
parents ad5cd8dd99b3
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();