int main(int argc,char **argv) { ALvoid *data; ALsizei bits,freq,size; ALenum format; ALboolean success; // Default packet size (in bytes) // Note that this doesn't necessarily have to have anything to do with the // buffer size of the receiver. Just set it to something appropriate // (depending on the connection), and the receiver will take care of the // playing the sound correctly... unsigned int packetsize=10000; const char defaultfile[]="bee.wav"; const char *filename; if(argc>1) filename=argv[1]; else filename=defaultfile; if(argc>2) packetsize=atoi(argv[2]); try { success=alutLoadWAV(filename,&data,&format,&size,&bits,&freq); std::cerr << "Bits: " << bits << " Freq: " << freq << std::endl; if(success==AL_FALSE) { std::cerr << "Error loading " << filename << "\n"; exit(1); } UDPSocket socket; socket.setPeer(InetHostAddress("127.0.0.1"),33333); int totalsent=0; while(totalsent<size) { // Send data in packets with a 60 ms delay between packets if((totalsent+packetsize)>size) packetsize=size-totalsent; totalsent+=socket.send((char *)data+totalsent,packetsize); ost::Thread::sleep(60); } free(data); } catch(...) { std::cerr << "Error caught!\n"; } return 0; }