giuliomoro@24: /* UDP client in the internet domain */ giuliomoro@24: #include giuliomoro@24: #include giuliomoro@24: #include giuliomoro@24: #include giuliomoro@24: #include giuliomoro@24: #include giuliomoro@24: #include giuliomoro@24: #include giuliomoro@24: #include giuliomoro@24: giuliomoro@24: struct networkData{ giuliomoro@24: int *counter; giuliomoro@24: float *variables[16]; giuliomoro@24: int numVariables; giuliomoro@24: }; giuliomoro@41: #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: struct networkAudio{ giuliomoro@41: int timestamp; giuliomoro@41: int currentBuffer; giuliomoro@41: int index; giuliomoro@41: float buffers[2][NETWORK_AUDIO_BUFFER_SIZE]; giuliomoro@41: int doneOnTime; giuliomoro@54: bool toBeSent; giuliomoro@54: UdpClient udpClient; giuliomoro@41: }; giuliomoro@24: giuliomoro@24: void error(const char *); giuliomoro@24: int setupSockets(int receivePort, int transmitPort, char const*serverName); giuliomoro@24: int sendMessage(networkData message); giuliomoro@41: int sendAudio(networkAudio *audio); giuliomoro@24: int receiveMessage(networkData message); giuliomoro@24: void closeSockets();